允许未经身份验证的用户使用ASP.Net表单身份验证访问特定页面

前端之家收集整理的这篇文章主要介绍了允许未经身份验证的用户使用ASP.Net表单身份验证访问特定页面前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我使用ASP.Net表单验证。我的Web.config看起来像这样。
<authentication mode="Forms">
      <forms loginUrl="login.aspx"/>
    </authentication>
    <authorization>
      <deny users="?" />
    </authorization>

因此,目前每个aspx页面都需要身份验证。

我想允许甚至未经身份验证的用户访问名为special.aspx的特定页面
我如何做到这一点?

解决方法

看看 MS Support的例子
<configuration>
    <system.web>
        <authentication mode="Forms" >
            <forms loginUrl="login.aspx" name=".ASPNETAUTH" protection="None" path="/" timeout="20" >
            </forms>
        </authentication>
<!-- This section denies access to all files in this 
application except for those that you have not explicitly 
specified by using another setting. -->
        <authorization>
            <deny users="?" /> 
        </authorization>
    </system.web>
<!-- This section gives the unauthenticated 
user access to the ThePageThatUnauthenticatedUsersCanVisit.aspx 
page only. It is located in the same folder 
as this configuration file. -->
        <location path="ThePageThatUnauthenticatedUsersCanVisit.aspx">
        <system.web>
        <authorization>
            <allow users ="*" />
        </authorization>
        </system.web>
        </location>
<!-- This section gives the unauthenticated 
user access to all of the files that are stored 
in the TheDirectoryThatUnauthenticatedUsersCanVisit folder.  -->
        <location path="TheDirectoryThatUnauthenticatedUsersCanVisit">
        <system.web>
        <authorization>
            <allow users ="*" />
        </authorization>
        </system.web>
        </location>
</configuration>
原文链接:https://www.f2er.com/aspnet/254266.html

猜你在找的asp.Net相关文章