HTTP 错误 500.19 和错误代码:0x80070021

问题描述:

我有一个由 Visual Studio 2013 构建的简单 webAPI.当我从 VS13 运行它时效果很好,但是当我在本地 IIS 中复制项目时,它给了我以下错误.

I have a simple webAPI build by Visual Studio 2013. It works well when I run it from VS13 but when I copy the project in local IIS it gives me the following error.

HTTP 错误 500.19 - 内部服务器错误 请求的页面不能因为页面的相关配置数据被访问无效.

HTTP Error 500.19 - Internal Server Error The requested page cannot be accessed because the related configuration data for the page is invalid.

详细错误信息:

模块 IIS Web 核心

Module IIS Web Core

通知开始请求

处理者尚未确定

错误代码 0x80070021

Error Code 0x80070021

配置错误 此配置部分无法在此路径中使用.当该部分锁定在父级别时会发生这种情况.锁定要么是默认的 (overrideModeDefault="Deny"),要么是由带有 overrideMode="Deny" 或旧版 allowOverride="false" 的位置标签显式设置.

Config Error This configuration section cannot be used at this path. This happens when the section is locked at a parent level. Locking is either by default (overrideModeDefault="Deny"), or set explicitly by a location tag with overrideMode="Deny" or the legacy allowOverride="false".

配置文件 ?C:inetpubwwwrootAPITeslinweb.config

Config File ?C:inetpubwwwrootAPITeslinweb.config

配置源:

36:   <system.webServer>  
37:     <handlers>  
38:       <remove name="ExtensionlessUrlHandler-Integrated-4.0" />

得到了完全相同的错误并来到了这个问题.正如@SpaceBison 在评论中提到的,这个答案描述了解决方案 - https://stackoverflow.com/a/12867753/404099.我发现它太晚了,它错过了一些步骤.这对我有用:

Got precisely the same error and came to this question. As @SpaceBison mentioned in comments, this answer describes the solution - https://stackoverflow.com/a/12867753/404099. I spotted it too late and it misses some steps. This is what worked for me:

Windows Server 2012,IIS 8.5.应该也适用于其他版本.

Windows Server 2012, IIS 8.5. Should work for other versions too.

  • 转到服务器管理器,点击添加角色和功能
  • 在角色部分选择:Web Server
    • 在安全子部分下选择所有内容(我排除了摘要、IP 限制和 URL 授权,因为我们不使用它们)
    • 在 Application Development 下,选择 .NET Extensibility 4.5、ASP.NET 4.5 和两个 ISAPI 条目