使用Forms验证,要实现对某个目录下的文件或某个文件不验证,可以按照如下方式来解决:

在Web.Config的<configuration>节下加入如下配置节:

1ASP.NET Web下基于Forms的验证<location path="frmRegister.aspx"><!--此处的path若为某文件夹,则该文件夹下的文件不用验证,如path="public",则public下的所有文件不验证,若为path="pubilc/index.aspx"则public/index.aspx文件不验证-->
2ASP.NET Web下基于Forms的验证  <system.web>
3ASP.NET Web下基于Forms的验证   <authorization>
4ASP.NET Web下基于Forms的验证    <allow users="*"/>
5ASP.NET Web下基于Forms的验证   </authorization>
6ASP.NET Web下基于Forms的验证  </system.web>
7ASP.NET Web下基于Forms的验证 </location>


在<System.Web>配置节下加入如下配置节:
1ASP.NET Web下基于Forms的验证<authentication mode="Forms">
2ASP.NET Web下基于Forms的验证            <forms name=".LoginUser" loginUrl="default.aspx" protection="All" timeout="30" />
3ASP.NET Web下基于Forms的验证 </authentication>
4ASP.NET Web下基于Forms的验证  <authorization>
5ASP.NET Web下基于Forms的验证     <deny users="?"/>
6ASP.NET Web下基于Forms的验证      <allow users="*" />
7ASP.NET Web下基于Forms的验证  </authorization>

即可达到验证的效果,代码非常简单,不做解释了。

相关文章:

猜你喜欢
  • 2022-12-23
  • 2021-06-24
  • 2022-01-17
  • 2022-01-10
相关资源
相似解决方案