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

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

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

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

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


当前回答

Powershell启用功能的方式(Windows Server 2012+)-根据需要进行微调:

Install-WindowsFeature NET-Framework-Core
Install-WindowsFeature Web-Server -IncludeAllSubFeature
Install-WindowsFeature NET-Framework-Features -IncludeAllSubFeature
Install-WindowsFeature NET-Framework-45-ASPNET -IncludeAllSubFeature
Install-WindowsFeature Application-Server -IncludeAllSubFeature
Install-WindowsFeature MSMQ -IncludeAllSubFeature
Install-WindowsFeature WAS -IncludeAllSubFeature

其他回答

您也可以使用IIS管理器来编辑这些设置。

关注本学习IIS文章:

从IIS根目录使用功能委派:

然后,您可以控制每一个计算机级读/写权限,否则将导致overrideMode=“拒绝”错误。

以下内容对我有用:

转到项目财产。Web选项卡。设置为本地IIS并设置特定页面。

我有Windows 7和Visual Studio 2013。

Powershell启用功能的方式(Windows Server 2012+)-根据需要进行微调:

Install-WindowsFeature NET-Framework-Core
Install-WindowsFeature Web-Server -IncludeAllSubFeature
Install-WindowsFeature NET-Framework-Features -IncludeAllSubFeature
Install-WindowsFeature NET-Framework-45-ASPNET -IncludeAllSubFeature
Install-WindowsFeature Application-Server -IncludeAllSubFeature
Install-WindowsFeature MSMQ -IncludeAllSubFeature
Install-WindowsFeature WAS -IncludeAllSubFeature

就我而言,这是另一回事。

当我在新版本的Visual Studio中加载解决方案时,VS显然创建了一个新的特定于项目的applicationhost.config文件:

MySolutionDir\.vs\config\applicationhost.config

它开始使用新配置中的设置,而不是我已经自定义的全局IIS Express设置。(\Users\%USER%\Documents\IISExpress\config\applicationhost.config)

在我的情况下,这是需要设置的设置。当然,这对你来说可能是另外一件事:

<section name="ipSecurity" overrideModeDefault="Allow" />

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

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

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