.net中验证用户安全信息
2013-12-13 09:25
253 查看
FormsAuthentication里有SetAuthCookie和RedirectFromLoginPage两个方法将用户的登陆信息(标记)记录到Cookie中
而Forms认证方式中的HttpContext.Current.User.Identity.IsAuthenticated;依赖于这个Cookie里的信息判断用户是否登陆。
FormsAuthentication.SignOut用来清除这个Cookie标记
用法如下
FormsAuthentication.SetAuthCookie(userID, createPersistentCookie);
FormsAuthentication.RedirectFromLoginPage(userID, createPersistentCookie);
其中userID可以在HttpContext.Current.User.Identity.Name;或者Page.User.Identifiy.Name;中重新获得
注意:以上是form验证信息 需要在webconfig中 验证方式改为 Forms <authentication mode="Forms" />
而Forms认证方式中的HttpContext.Current.User.Identity.IsAuthenticated;依赖于这个Cookie里的信息判断用户是否登陆。
FormsAuthentication.SignOut用来清除这个Cookie标记
用法如下
FormsAuthentication.SetAuthCookie(userID, createPersistentCookie);
FormsAuthentication.RedirectFromLoginPage(userID, createPersistentCookie);
其中userID可以在HttpContext.Current.User.Identity.Name;或者Page.User.Identifiy.Name;中重新获得
注意:以上是form验证信息 需要在webconfig中 验证方式改为 Forms <authentication mode="Forms" />
相关文章推荐
- Asp.net+Jquery实现用户信息异步验证
- asp.net 下利用DirectoryEntry验证用户及获取域控制器下的用户结构信息
- asp.net用户身份验证时读不到用户信息的问题 您的登录尝试不成功。请重试。 Login控件
- NET 实现自定义ContextUser的Identity和Principal实现自定义用户信息,权限验证
- ASP.NET中启用Windows集成验证,怎样在调用System.DirectoryServices下的组件时传递安全上下文,也就是说当前用户凭据,来实现权限管理
- asp.net用户身份验证时读不到用户信息的问题 您的登录尝试不成功。请重试。 Login控件
- Asp.net+Jquery实现用户信息异步验证
- Asp.net和Jquery实现用户信息异步验证
- Asp.net和Jquery实现用户信息异步验证
- Asp.net+Jquery实现用户信息异步验证
- 非空验证 注册用户信息
- ASP.NET MVC生成安全验证码
- ASP.net Logion用户登陆验证代码
- asp.net中访问SQL Server数据库采用windows集成安全验证
- Asp.net2.0身份验证技术学习入门---新用户注册,登录,显示用户信息
- ASP.NET MVC5+MySql使用ASP.NET 身份验证实现用户和角色功能 1 概述 目标:使用MySql数据库,建立一个使用ASP.NET 身份验证的应用,并实现角色功能,身份
- 使用ASP.NET 2.0 Profile存储用户信息
- 使用ASP.NET 2.0 Profile存储用户信息[翻译] Level 200
- 使用SpringSecurity3用户验证(异常信息,验证码)
- CAS认证(3):验证用户信息