利用FormsAuthentication.RedirectFromLoginPage进行身份验证
web.config中:
格式:
//I.Name: 指定完成身份验证的Http cookie的名称. II.LoginUrl: 如果未通过验证或超时后重定向的页面URL,一般为登录页面,让用户重新登录 III.Protection: 指定 cookie数据的保护方式[a. All表示加密数据,并进行有效性验证两种方式 b. None表示不保护Cookie. c. Encryption表示对Cookie内容进行加密 d. validation表示对Cookie内容进行有效性验证]. IV. TimeOut: 指定Cookie的失效时间. 超时后要重新登录.
login.aspx中:
FormsAuthentication.RedirectFromLoginPage(userid,false); //重新定位至前一个页面
Response.Redirect("zzz.aspx");
//RedirectFromLoginPage是封装了传登录信息,必须要是 mode="Forms"才能传,Response.Redirect转页。
//得这个值是Page.User.Identity.Name[其中存贮着userid]
//与GetRedirectUrl区别:后者存储defaultUrl="default.aspx"中定义的位置
清除forms验证的办法:
FormsAuthentication.SignOut();
转载自:http://hi.baidu.com/yfqsdie/item/36338cbe7df31ca0ebba9331