您的位置:首页 > 其它

.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" />
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: