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

王朝c#·作者佚名  2006-12-17
宽屏版  字体: |||超大  

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

1: 在web.config中,加入form认证;

<authentication mode='Forms'>

<forms name='auth' loginUrl='index.aspx' timeout='30'></forms>

</authentication>

<authorization>

<deny users='?' />

</authorization>

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

以下代码应该在<configuration><system.web>之间,而不应该包含到<system.web>..</system.web>之间;

----------------表示允许 匿名用户对 userReg.aspx页面进行访问.

<location path='userReg.aspx'>

<system.web>

<authorization>

<allow users='?' />

</authorization>

</system.web>

</location>

3 在登录成功后要 创建身份验证票, 表明已经通过认证的合法用户;

if(登陆成功)

System.Web.Security.FormsAuthentication.SetAuthCookie(用户名称, false);

 
 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
© 2005- 王朝网络 版权所有