我正在使用FormsAuthentication.FormsCookieName处理WebApplication。我在WebConfig中有这个:
<httpCookies requireSSL="true" />
<authentication mode="Forms">
<forms cookieless="UseCookies"
name=".ASPXAUTH1" />
</authentication>
代码:
var httpCookie = new HttpCookie(FormsAuthentication.FormsCookieName, FormsAuthentication.Encrypt(ticket))
{
HttpOnly = true,
Domain = "." +host, // Ex- host = google.com (without www because we use subdomains)
Secure = false
};
httpCookie.Expires = remember ? DateTime.Now.Add(FormsAuthentication.Timeout) : DateTime.Now.AddMinutes(1);
当我登录网络应用程序时,一切看起来都不错:
红色箭头= .google.com
的域名几秒钟后,第二个Cookie会显示不同的域= www.google.com和过期日期
我没有使用RedirectToLoging Page Method。
答案 0 :(得分:0)
解决了在webconfig中添加slidingExpiration属性的问题
<authentication mode="Forms" >
<forms cookieless="UseCookies" name=".ASPXAUTH" slidingExpiration="false" />