当前位置: 首页 > 图文教程 > 网络编程 > ASP.NET > asp.net 关于form认证的一般设置

ASP.NET
ewebeditor在.net的使用方法
Server.Transfer,Response.Redirect的区别
ASP.NET2.0+SQL Server2005构建多层应用
ASP.NET 2.0 中收集的小功能点(转)
ASP.Net全局变量的设置和读取方法
数据库开发总结(ADO.NET小结)
ASP.net(c#)打造24小时天气预报及实时天气
发布WEB站点时出现Server Application Unavailable
在asp.net中实现datagrid checkbox 全选的方法
ASP.NET 2.0 URL映射技巧
ConfiguraionSource节点及多个配置文件的应用
SqlConnection.ConnectionString相关关键字
如何在WebForm中使用javascript防止连打(双击)
看到本质而不是现象--解决ASP.NET CS0016的问题
学会区分Visual Studio 2005,Visual Studio 2005 Team System和MSDN Premium 订阅的各个版本
ASP.NET 入门的五个步骤
ASP.NET 高性能分页代码
动态ItemTemplate的实现(译) - item,template
遍历Hashtable 的几种方法
通过VS中的数据源选择对话框简单实现数据库连接配置

ASP.NET 中的 asp.net 关于form认证的一般设置


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-11-03   浏览: 190 ::
收藏到网摘: n/a

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);