config文件中设置:

 
<authentication mode="Forms">
      
<forms loginUrl="Login.aspx"    timeout="30"     /> 
    
</authentication>
    
<authorization>
      
<deny   users="?"   />
    
</authorization>

登录成功后代码:

 FormsAuthentication.RedirectFromLoginPage(
"userName"false);//false或者true都可以

注销代码:

 System.Web.Security.FormsAuthentication.SignOut();

其他参考:

<system.web> 
  <authentication mode
="Forms"> 
    <forms loginUrl
="Login.ASPx" 
           protection
="All" 
           timeout
="30" 
           name
=".ASPXAUTH"  
           path
="/" 
           requireSSL
="false" 
           slidingExpiration
="true" 
           defaultUrl
="default.ASPx" 
           cookieless
="UseDeviceProfile" 
           enableCrossAppRedirects
="false" /> 
  <
/authentication> 
/system.web> 
posted on 2007-07-12 12:14  阳春  阅读(271)  评论(0)    收藏  举报