我在将站点部署到服务器时遇到错误。尝试加载主页或在IIS中的新站点上访问身份验证时,我收到错误:

配置错误:无法在此路径上使用此配置节。当节在父级锁定时,会发生这种情况。锁定是默认情况下(overrideModeDefault=“Deny”),或由具有overrideMode=“拒绝”或旧版的位置标记allowOverride=“false”。

更多细节可以在这里找到,在场景7中匹配我的十六进制错误代码。

上面链接站点上给出的解决方案是在applicationHost.config文件中的错误部分中设置Allow for overrideModeDefault。在我的例子中,在system.webServer中的“安全”下。但如果我查看本地计算机上的applicationHost.config(该站点已正确部署),则该部分设置为“拒绝”。

如果此解决方案是正确的,那么我的本地实例在使用相同的web.config时如何正常运行?根据我的applicationHost.config,该部分应该被锁定,但实际上没有。我宁愿不更改applicationHost.config文件,因为该服务器上还有许多其他站点在运行。还有其他解决方案吗?


当前回答

在我的案例中,服务器上未启用.NET Framework功能下的“HTTP激活”。因此,对于Windows Server 2012,对我有效的解决方案是:

服务器管理器->添加角色和功能->功能->确保在要使用的.NET Framework版本下选中“HTTP激活”

其他回答

在带有IIS 8的Windows Server 2012上,我通过启用ASP.NET 4.5功能解决了这一问题:

然后跟随肯的回答。

要解决此问题,请打开IIS Express applicationhost.config。此文件存储在C:\Users[您的用户名]\Documents\IISExpress\config\applicationhost.config中

VS2015+的更新:config文件位置为$(solutionDir).vs\config\applicationhost.config

查找以下行

<section name="windowsAuthentication" overrideModeDefault="Deny" />
<section name="anonymousAuthentication" overrideModeDefault="Deny" />
<add name="WindowsAuthenticationModule" lockItem="true" />
<add name="AnonymousAuthenticationModule" lockItem="true" />

将这些行更改为

<section name="windowsAuthentication" overrideModeDefault="Allow" />
<section name="anonymousAuthentication" overrideModeDefault="Allow" />
<add name="WindowsAuthenticationModule" lockItem="false" />
<add name="AnonymousAuthenticationModule" lockItem="false" />

保存并刷新Asp.net页面。

我注意到一个类似的答案,但在我的案例中,我使用IIS配置编辑器来查找我想要“解锁”的部分。

然后我复制了路径并在我的自动化中使用它来解锁,然后再更改我想要编辑的部分。

. "$($env:windir)\system32\inetsrv\appcmd" unlock config -section:system.webServer/security/authentication/windowsAuthentication
. "$($env:windir)\system32\inetsrv\appcmd" unlock config -section:system.webServer/security/authentication/anonymousAuthentication

我从提升的命令提示符运行了以下两个命令:

%windir%/system32/inetsrv/appcmd unlock config /section:anonymousAuthentication

%windir%/system32/inetsrv/appcmd unlock config /section:windowsAuthentication

当我收到这条漂亮的消息时,我需要更改子文件夹上的SSL设置。在我的情况下,接下来的行动帮助了我。

已打开C:\Windows\System32\inetsrv\config\applicationHost.config

并将值从overrideModeDefault=“拒绝”更改为“允许”

<sectionGroup name="system.webServer">
 ...
    <sectionGroup name="security">
        <section name="access" overrideModeDefault="Allow" />
    </sectionGroup>