表单身份验证(受保护的目录)
根目录下的 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
{
![](/Images/OutliningIndicators/InBlock.gif)
}
根目录下新建一个受保护的目录...
这个目录下的 web.config
<configuration>
<system.web>
<authorization>
<deny users="?" />
</authorization>
</system.web>
</configuration>
demo
https://files.cnblogs.com/gwazy/WebApplication7.rar
![](/Images/OutliningIndicators/None.gif)
![](/Images/OutliningIndicators/None.gif)
![](/Images/OutliningIndicators/None.gif)
![](/Images/OutliningIndicators/None.gif)
bb.aspx
![](/Images/OutliningIndicators/None.gif)
![](/Images/OutliningIndicators/ExpandedBlockStart.gif)
![](/Images/OutliningIndicators/InBlock.gif)
![](/Images/OutliningIndicators/InBlock.gif)
![](/Images/OutliningIndicators/ExpandedBlockEnd.gif)
![](/Images/OutliningIndicators/None.gif)
![](/Images/OutliningIndicators/ExpandedBlockStart.gif)
![](/Images/OutliningIndicators/InBlock.gif)
![](/Images/OutliningIndicators/ExpandedBlockEnd.gif)
![](/Images/OutliningIndicators/None.gif)
这个目录下的 web.config
![](/Images/OutliningIndicators/None.gif)
![](/Images/OutliningIndicators/None.gif)
![](/Images/OutliningIndicators/None.gif)
![](/Images/OutliningIndicators/None.gif)
![](/Images/OutliningIndicators/None.gif)
![](/Images/OutliningIndicators/None.gif)
![](/Images/OutliningIndicators/None.gif)
demo
https://files.cnblogs.com/gwazy/WebApplication7.rar