日期:2010-06-16  浏览次数:20433 次

(1)在Web.config的配置   
   在<system.web>中修改选项
     验证模式设为Form,并且验证页为
      <authentication mode="Forms">
        <forms loginUrl="Login.aspx" />
      </authentication>
     不允许匿名用户
      <authorization>
        <deny users="?" />
      </authorization>

   在</system.web>后加入不要验证就能使用数据库的页面,用于在该页访问数据库,察看是否存在该用户。
     <location path="Reg.aspx">
       <system.web>
         <authorization>
           <allow users="*"/>
         </authorization>
       </system.web>
     </location>

  (2)在代码中按普通方式,例如要求对方输入信息查找数据库或者XML进行验证,验证通过后,执行这句就表示验证通过同时跳会开始进入的页面
      System.Web.Security.FormsAuthentication.RedirectFromLoginPage(userName,true);
      注销用 System.Web.Security.FormsAuthentication.SignOut();  
      如果不想跳回原处,可以先授权再redirect到其他页面  System.Web.Security.FormsAuthentication.SetAuthCookie();