您的位置:首页 > 编程语言 > ASP

ASP.NET 自带的用户验证 COOKIE 过期之谜

2009-09-04 13:55 381 查看
1、模拟 IIS 验证的帐户或用户

 若要在收到 ASP.NET 应用程序中每个页的每个请求时模拟
Microsoft Internet 信息服务 (IIS) 身份验证用户,必须在此应用程序的 Web.config 文件中包含
<identity> 标记,并将 impersonate 属性设置为 true

 

 

 

 

WEB.config 配置

 

<identity impersonate="true" />
<authentication mode="Forms">
<forms name="CSDN" path="/" loginUrl="~/Login.aspx"  protection="All" timeout="7200"></forms>
</authentication>


 

 实现接口  System.Security.Principal.IPrincipal

//HttpContext.Current.User = newUser;
if (AutoLogin.Checked)
{
FormsAuthentication.SetAuthCookie(UserName.Text, true);
HttpCookie httpCookie = new HttpCookie("UserName", UserName.Text);
httpCookie.Expires = DateTime.Now.AddYears(1);
Response.Cookies.Add(httpCookie);
}


 

到现在是哪个过期时间在起作用我还比较纳闷!
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
相关文章推荐