【问题标题】:Web.config Forms Auth > protect root but allow access to subdirectoryWeb.config Forms Auth > 保护根目录但允许访问子目录
【发布时间】:2012-04-10 10:41:49
【问题描述】:

这是我的问题...

我有一个在 II7 集成管道模式下运行的网站,我想在整个网站上启用表单身份验证,除了包含登录表单的“/secure/”目录。

我的网络配置目前看起来像这样......

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.web>
        <customErrors mode="Off"/>
        <authentication mode="Forms">
            <forms name=".ASPXAUTH" loginUrl="secure/login.aspx" protection="All" path="/" timeout="999999" slidingExpiration="true" enableCrossAppRedirects="true">
                <credentials passwordFormat="Clear">
                    <user name="user1" password="xxxxxx"/>
                </credentials>
            </forms>
        </authentication>
        <authorization>
            <allow users="user1"/>
            <deny users="*"/>
        </authorization>    
    </system.web>
    <location path="secure">
        <system.web>
            <authorization>
                <allow users="*"/>
            </authorization>
        </system.web>
    </location>
    <system.webServer>
        <!--Enabling Forms Authentication for the Entire Application-->
        <modules> 
            <remove name="FormsAuthenticationModule" />    
            <add name="FormsAuthenticationModule" type="System.Web.Security.FormsAuthenticationModule" />    
            <remove name="UrlAuthorization" />    
            <add name="UrlAuthorization" type="System.Web.Security.UrlAuthorizationModule" />    
            <remove name="DefaultAuthentication" />    
            <add name="DefaultAuthentication" type="System.Web.Security.DefaultAuthenticationModule" />    
        </modules>
    </system.webServer>
</configuration>

当我访问网站 URL 时,我会得到一个无限循环的重定向。我尝试将特定位置的身份验证规则放在 system.web 部分之上,但这没有效果。

有什么想法吗?

干杯,

罗宾

【问题讨论】:

    标签: asp.net iis iis-7 web-config forms-authentication


    【解决方案1】:

    访问权限是分层的。也就是说,如果您被禁止访问某个父级,则无论为子级设置什么权限,您都被禁止访问其所有子级。 您可以将登录表单移动到根目录并为表单设置权限 - 它会起作用。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2014-01-20
      • 1970-01-01
      • 2017-05-22
      • 2019-03-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多