我们有一个 .NET MVC 4 网站,该网站位于 IIS 7 中。我们已配置为具有安全身份验证Cookie。我们需要登录才能通过SSL安全。
在我们放置的网络配置中
<authentication mode="Forms">
<forms loginUrl="~/Login" timeout="2880" requireSSL="true" domain="domain.com"/>
</authentication>
在Login控制器中,我们设置了身份验证cookie的值
var authenticationTicket = new FormsAuthenticationTicket(1, Email, DateTime.Now, DateTime.Now.AddMinutes(30), false, userData);
string encrypt = FormsAuthentication.Encrypt(authenticationTicket);
Response.Cookies.Add(new HttpCookie(FormsAuthentication.FormsCookieName, encrypt)
{
HttpOnly = true,
Secure = FormsAuthentication.RequireSSL,
Path = FormsAuthentication.FormsCookiePath,
Domain = FormsAuthentication.CookieDomain
});
但是当你尝试登录时,cookie显示为安全但用户无法登录;站点重定向回登录页面(找到HTTP 302)。
问题:我们如何正确配置?
提前致谢。