码迷,mamicode.com
首页 > 其他好文 > 详细

利用FormsAuthentication.RedirectFromLoginPage进行身份验证

时间:2014-05-15 17:12:14      阅读:279      评论:0      收藏:0      [点我收藏+]

标签:c   http   get   com   a   数据   

 

web.config中:  

<authentication>节

格式:

<authentication mode="Forms">    //I.Windows: 使用IIS验证方式     II.Forms: 使用基于窗体的验证方式     III.Passport: 采用Passport cookie验证模式      IV.None: 不采用任何验证方式

         <forms name=".ASPXUSERDEMO" loginUrl="Login.aspx" protection="All" timeout="30" defaultUrl="default.aspx"/>      

         //I.Name: 指定完成身份验证的Http cookie的名称.     II.LoginUrl: 如果未通过验证或超时后重定向的页面URL,一般为登录页面,让用户重新登录     III.Protection: 指定 cookie数据的保护方式[a. All表示加密数据,并进行有效性验证两种方式 b. None表示不保护Cookie. c. Encryption表示对Cookie内容进行加密 d. validation表示对Cookie内容进行有效性验证].      IV. TimeOut: 指定Cookie的失效时间. 超时后要重新登录.

</authentication>

<authorization>

         <deny users="?"/>          //此处如果该为*,则针对所有用户,包过通过验证的用户都起作用

</authorization>

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

利用FormsAuthentication.RedirectFromLoginPage进行身份验证,布布扣,bubuko.com

利用FormsAuthentication.RedirectFromLoginPage进行身份验证

标签:c   http   get   com   a   数据   

原文地址:http://www.cnblogs.com/Sabra/p/3729889.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!