asp.net的forms身份验证 单用户身份验证

asp.net的forms身份验证  单用户身份验证

首先要配置Web.config文件

<system.web>
<authentication mode="Forms">
<forms loginUrl="logon.aspx" name=".ASPXFORMSAUTH">
</forms>
</authentication>
<authorization>
<deny users="?" />
</authorization>
</system.web>

创建Logon.aspx 和 Default.aspx两个页面

授权

FormsAuthentication.SetAuthCookie(UserEmail.Text,true);

或者

FormsAuthentication.RedirectFromLoginPage(UserEmail.Text, true);

 

取得身份信息

Context.User.Identity.Name

判断 Request.IsAuthenticated

posted @ 2017-10-28 13:58  花开而已  阅读(141)  评论(0编辑  收藏  举报