web.config中:
<authentication mode="Forms">
<forms name="login" loginUrl="login.aspx" timeout="60">
</forms>
</authentication>
login.aspx中:
FormsAuthentication.RedirectFromLoginPage(userid,false);
Response.Redirect("zzz.aspx");
RedirectFromLoginPage是封装了传登录信息,必须要是 mode="Forms"才能传,Response.Redirect转页。
得这个值是Page.User.Identity.Name
7.<authentication>节
格式:
<authentication mode="Forms">
<forms name=".ASPXUSERDEMO" loginUrl="Login.aspx" protection="All" timeout="30"/>
</authentication>
<authorization>
<deny users="?"/>
</authorization>
I.Windows: 使用IIS验证方式
II.Forms: 使用基于窗体的验证方式
III.Passport: 采用Passport cookie验证模式
IV.None: 不采用任何验证方式
里面内嵌Forms节点的属性涵义:
I.Name: 指定完成身份验证的Http cookie的名称.
II.LoginUrl: 如果未通过验证或超时后重定向的页面URL,一般为登录页面,让用户重新登录
III.Protection: 指定 cookie数据的保护方式.
可设置为: All None Encryption Validation四种保护方式
a. All表示加密数据,并进行有效性验证两种方式
b. None表示不保护Cookie.
c. Encryption表示对Cookie内容进行加密
d. validation表示对Cookie内容进行有效性验证
IV. TimeOut: 指定Cookie的失效时间. 超时后要重新登录.