表单身份验证(受保护的目录)

根目录下的 web.config
<authentication mode="Forms">   <forms name=".COOKIEDEMO" loginUrl="bb.aspx" protection="All"
   timeout
="60" path="/"> 
      
</forms> 
        
</authentication>
 根目录下的. 
 bb.aspx
if (this.TextBox1 .Text=="abc" &&  this.TextBox2 .Text=="abc")
            
{
                System.Web.Security .FormsAuthentication .RedirectFromLoginPage(
this.TextBox1 .Text,false);
                
            }

            
else
            
{

            }

  根目录下新建一个受保护的目录...
    这个目录下的 web.config 
  
<configuration>
  
<system.web>
    
<authorization>
      
<deny users="?" />
    
</authorization>
  
</system.web>
</configuration>
 

demo

  https://files.cnblogs.com/gwazy/WebApplication7.rar


原文地址:https://www.cnblogs.com/gwazy/p/112643.html