asp.net 关于form认证的一般设置:

asp.net 关于form认证的一般设置:
1: 在web.config中,加入form认证;

1<authentication mode="Forms">
2<forms loginurl="index.aspx" name="auth" timeout="30"></forms>
3</authentication>
1<authorization>
2<deny users="?"></deny>
3</authorization>

2: 如果有注册页面时还应该允许匿名用户调用注册页面进行注册;
以下代码应该在

 1<configuration><system.web>之间,而不应该包含到<system.web>..</system.web>之间;   
 2\----------------表示允许 匿名用户对 userReg.aspx页面进行访问.   
 3<location path="userReg.aspx">
 4<system.web>
 5<authorization>
 6<allow users="?"></allow>
 7</authorization>
 8</system.web>
 9</location>   
103 在登录成功后要 创建身份验证票, 表明已经通过认证的合法用户; 
11
12if(登陆成功) 
13
14System.Web.Security.FormsAuthentication.SetAuthCookie(用户名称, false);</system.web></configuration>
Published At
Categories with Web编程
Tagged with
comments powered by Disqus