【发布时间】:2010-10-25 19:33:28
【问题描述】:
我有一个基于 SSL 的 ASP:NET MVC 2 网站。我想创建一个这样的cookie:
FormsAuthentication.SetAuthCookie(validatedUser.UserName, false);
FormsAuthenticationTicket authTicket = new FormsAuthenticationTicket(1, validatedUser.SecureToken, DateTime.Now, DateTime.Now.AddMinutes(10), false, String.Empty);
HttpCookie cookie = new HttpCookie(FormsAuthentication.FormsCookieName, FormsAuthentication.Encrypt(authTicket));
Response.Cookies.Add(cookie);
但我得到一个例外,告诉:“应用程序配置为发出安全 cookie。这些 cookie 要求浏览器通过 SSL(https 协议)发出请求。但是,当前请求不是通过 SSL。 ”
在 web.config 我有:
<authentication mode="Forms">
<forms loginUrl="~/Account/LoginError" timeout="2880" requireSSL="true" protection="All"/>
</authentication>
我该如何解决这个问题?
【问题讨论】:
-
有人读过这个吗? codebutler.com/firesheep
标签: asp.net-mvc-2 cookies ssl https