我的 web.config 中有这个部分:
<system.webServer>
<modules runAllManagedModulesForAllRequests="true" />
<security>
<authentication>
<anonymousAuthentication enabled="true" />
<windowsAuthentication enabled="true" />
</authentication>
</security>
</system.webServer>
Run Code Online (Sandbox Code Playgroud)
IIS7 崩溃并抱怨身份验证部分:
模块 AnonymousAuthenticationModule
通知 AuthenticateRequest
Handler StaticFile
错误代码 0x80070021
配置错误 此配置部分不能在此路径使用。当该部分锁定在父级别时会发生这种情况。锁定要么是默认的 (overrideModeDefault="Deny"),要么是由带有 overrideMode="Deny" 或旧版 allowOverride="false" 的位置标记显式设置的。
Config Source
69: <authentication>
70: <anonymousAuthentication enabled="true" />
Run Code Online (Sandbox Code Playgroud)
所以解决这个问题的通常方法是进入%windir%\system32\inetsrv\config\applicationHost.config并解锁该部分:
<sectionGroup name="system.webServer">
<sectionGroup name="security">
<section name="access" overrideModeDefault="Deny" />
<section name="applicationDependencies" overrideModeDefault="Deny" />
<sectionGroup name="authentication">
<section name="anonymousAuthentication" overrideModeDefault="Allow" />
<section name="basicAuthentication" overrideModeDefault="Allow" />
<section name="clientCertificateMappingAuthentication" overrideModeDefault="Allow" />
<section name="digestAuthentication" overrideModeDefault="Allow" />
<section name="iisClientCertificateMappingAuthentication" overrideModeDefault="Allow" />
<section name="windowsAuthentication" overrideModeDefault="Allow" />
</sectionGroup>
Run Code Online (Sandbox Code Playgroud)
(或者,appcmd unlock config)。
奇怪的是:我已经这样做了,但它仍然抱怨。
我查找了 Locations(MVC 是我网站的名称,它是我正在使用的所有网站的根目录):
<location path="MVC" overrideMode="Allow">
<system.webServer overrideMode="Allow">
<security overrideMode="Allow">
<authentication overrideMode="Allow">
<windowsAuthentication enabled="true" />
<anonymousAuthentication enabled="true" />
</authentication>
</security>
</system.webServer>
</location>
Run Code Online (Sandbox Code Playgroud)
还是会炸。我很困惑为什么会发生这种情况。我无法从 web.config 中删除它,我想找到根本问题。
有没有办法从 IIS 获取特定信息,哪个规则最终拒绝了我?
编辑:我能够使用 IIS7 管理控制台解决这个问题,方法是转到根目录(我的机器)并单击“编辑配置”并解锁那里的部分。我仍然想知道是否有更好的方法,因为我找不到它实际修改的文件。
tom*_*ing 98
制定了这些步骤来解决我的问题:
system.webServer/security/authentication/anonymousAuthenticationsystem.webServer/security/authentication/windowsAuthentication小智 17
这解决了我在 Windows Server 2012、IIS 8.5 上的错误。也应该适用于其他版本。
.NET Extensibility 4.5and ASP>NET 4.5,两个 ISAPI 条目NET 3.5, .NET 4.5,ASP.NET 4.5Web Server (all), Management Tools (IIS Management Console and Management Service),Windows 配置锁定可能发生在:
Applicationhost.config(配置字符串:MACHINE/WEBROOT/APPHOST)
站点 Web.config 文件(MACHINE/WEBROOT/APPHOST/网站名称)
任何应用程序 web.config 文件(机器/WEBROOT/APPHOST/站点名称/应用程序名称)
锁定部分(部分:IIS 配置部分,例如<asp>)可让您拒绝将这些设置配置给层次结构中比您低的任何人。
使用 GUI 的功能委托并没有错,并且与 AppCMD 所做的非常相似,在幕后 -<location>在您关注的任何配置级别的标签中为给定部分设置 OverrideMode 。
APPCMD 可用于解锁文件,但请注意它所说的执行位置 - 在这方面它不如 GUI 聪明。
添加-commit:apphost到APPCMD UNLOCK命令末尾的目标 Applicationhost.config,它是IIS 操作的关键文件(替换早期版本的元数据库;存储所有集中设置,但允许在 web.config 文件中覆盖(如果你这样做))。
如果没有 -commit:apphost,APPCMD 将针对 web.config 文件的最接近的逻辑位置 - 无论是在站点级别还是应用程序级别,并使用上述设置的配置字符串指示它已更改设置。(另外:您仍然可以只针对子网站中的设置,但要提交给 apphost - 它使用位置标签来实现这一点)
因此,如果它说(内存释义)“更改已提交给 MACHINE/WEBROOT/APPHOST”,则表示 IIS 层次结构的顶层。
如果它说“提交到 MACHINE/WEBROOT/APPHOST/Dodgy 网站”,那意味着它查找 Dodgy 网站后面的物理路径,并在该位置编写了一个 web.config 文件(或更新了它)。
小智 5
如果您使用的是 IISExpress 和 Visual Studio 2015,applicationHost.config则存储在$(solutionDir).vs\config\applicationhost.config(感谢 Nime Cloud 的回答)。
只需overrideModeDefault="Allow"在适当的地方更改即可。
<sectionGroup name="security">
<section name="access" overrideModeDefault="Deny" />
<section name="applicationDependencies" overrideModeDefault="Deny" />
<sectionGroup name="authentication">
<section name="anonymousAuthentication" overrideModeDefault="Allow" />
etc...
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
206271 次 |
| 最近记录: |