asp.net-mvc HTTP 错误 500.19 和错误代码:0x80070021
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/20048486/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
HTTP Error 500.19 and error code : 0x80070021
提问by Umar Abbas
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.
我有一个由 Visual Studio 2013 构建的简单 webAPI。当我从 VS13 运行它时它运行良好,但是当我在本地 IIS 中复制项目时,它给了我以下错误。
HTTP Error 500.19 - Internal Server Error The requested page cannot be accessed because the related configuration data for the page is invalid.
HTTP 错误 500.19 - 内部服务器错误 无法访问请求的页面,因为该页面的相关配置数据无效。
Detailed Error Information:
详细错误信息:
ModuleIIS Web Core
模块IIS Web 核心
NotificationBeginRequest
通知开始请求
HandlerNot yet determined
处理程序尚未确定
Error Code0x80070021
错误代码0x80070021
Config ErrorThis 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".
配置错误此配置部分不能用于此路径。当该部分锁定在父级别时会发生这种情况。锁定要么是默认的 (overrideModeDefault="Deny"),要么是由带有 overrideMode="Deny" 或旧版 allowOverride="false" 的位置标记显式设置的。
Config File\?\C:\inetpub\wwwroot\APITeslin\web.config
配置文件\?\C:\inetpub\wwwroot\APITeslin\web.config
Config Source:
配置源:
36: <system.webServer>
37: <handlers>
38: <remove name="ExtensionlessUrlHandler-Integrated-4.0" />
回答by Ilia Barahovski
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:
得到了完全相同的错误并来到了这个问题。正如@SpaceBison 在评论中提到的,这个答案描述了解决方案 - https://stackoverflow.com/a/12867753/404099。我发现它太晚了,它错过了一些步骤。这对我有用:
Windows Server 2012, IIS 8.5. Should work for other versions too.
Windows Server 2012,IIS 8.5。也应该适用于其他版本。
- Go to server manager, click add roles and features
- In the roles section choose: Web Server
- Under Security sub-section choose everything (I excluded digest, IP restrictions and URL authorization as we don't use them)
- Under Application Development choose .NET Extensibility 4.5, ASP.NET 4.5 and both ISAPI entries
- In the features section choose: NET 3.5, .NET 4.5, ASP.NET 4.5
- In the web server section choose: Web Server (all), Management Tools (IIS Management Console and Management Service), Windows Authentication - if you are using any of it
- 转到服务器管理器,单击添加角色和功能
- 在角色部分选择:Web Server
- 在安全子部分下选择所有内容(我排除了摘要、IP 限制和 URL 授权,因为我们不使用它们)
- 在 Application Development 下选择 .NET Extensibility 4.5、ASP.NET 4.5 和两个 ISAPI 条目
- 在功能部分选择:NET 3.5、.NET 4.5、ASP.NET 4.5
- 在 Web 服务器部分选择:Web 服务器(全部)、管理工具(IIS 管理控制台和管理服务)、Windows 身份验证 - 如果您正在使用其中任何一个
回答by Sudhanshu Mishra
I got this error while trying to host a WCF service in an empty ASP.NET application. The whole solution was using .NET 4.5 platform, on IIS 8.5 running on Windows 8.1. The gotcha was to
我在尝试在空的 ASP.NET 应用程序中托管 WCF 服务时遇到此错误。整个解决方案使用 .NET 4.5 平台,在 Windows 8.1 上运行的 IIS 8.5 上。问题是
- Open up "Turn Windows Features on or off"
- Go to WCF section under ASP.NET 4.5 advanced services
- Check HTTP Activation.
You'll be asked to restart the system.

- 打开“打开或关闭 Windows 功能”
- 转到 ASP.NET 4.5 高级服务下的 WCF 部分
- 检查 HTTP 激活。
系统会要求您重新启动系统。

This should Fix the HTTP 500.19!
这应该修复 HTTP 500.19!
EDIT 11-FEB-2016Just got an issue on Windows 10 Pro, IIS 10, This time, it was an HTTP 404.0. The fix is still the same, turn on "HTTP Activation" under Windows Features -> .NET Framework 4.6 Advanced Services -> WCF Services -> HTTP Activation
编辑 2016 年 2 月 11 日刚刚在 Windows 10 Pro、IIS 10 上遇到问题,这次是 HTTP 404.0。修复还是一样,在Windows Features -> .NET Framework 4.6 Advanced Services -> WCF Services -> HTTP Activation下开启“HTTP Activation”
回答by SeeTheC
I also was getting the same problem but after brain storming with IIS and google for many hours. I found out the solution.
This error is because some settings are disabled in IIS applicationHost.config.
我也遇到了同样的问题,但在与 IIS 和 google 进行了数小时的头脑风暴之后。我找到了解决方案。此错误是因为某些设置在 IIS 中被禁用applicationHost.config。
Below are the steps to solution:
下面是解决步骤:
- Go to
C:\Windows\System32\inetsrv\config\applicationHost.configand open in notepad Change the following key value present in
<section name="handlers" overrideModeDefault="Deny" />change this value from "Deny" to "Allow"<section name="modules" allowDefinition="MachineToApplication" overrideModeDefault="Deny" />change this value from "Deny" to "Allow"
- 转到
C:\Windows\System32\inetsrv\config\applicationHost.config并在记事本中打开 更改中存在的以下键值
<section name="handlers" overrideModeDefault="Deny" />将此值从“拒绝”更改为“允许”<section name="modules" allowDefinition="MachineToApplication" overrideModeDefault="Deny" />将此值从“拒绝”更改为“允许”
It worked for me.
它对我有用。
回答by Ibrahim Dauda
If you're running IIS on that computer for the first time, you should try running the ASP.NET IIS registration tool (aspnet_regiis.exe).
如果您是第一次在该计算机上运行 IIS,您应该尝试运行 ASP.NET IIS 注册工具 (aspnet_regiis.exe)。
Here's how to do that: If you're using .net framework v4, open command prompt as an administrator, and change directory to your .net framework base folder using:
操作方法如下:如果您使用的是 .net framework v4,请以管理员身份打开命令提示符,然后使用以下命令将目录更改为 .net framework 基本文件夹:
CD C:\Windows\Microsoft.NET\Framework\v4.0.30319
or, if you're using a 64 bit computer, use:
或者,如果您使用的是 64 位计算机,请使用:
CD C:\Windows\Microsoft.NET\Framework64\v4.0.30319
when you've successfully navigated to the appropriate directory, execute the ASP.NET IIS registration tool using:
成功导航到适当的目录后,使用以下命令执行 ASP.NET IIS 注册工具:
aspnet_regiis -i
If you're using a different .NET framework version, simply replace v4.0.30319with the appropriate folder name.
如果您使用不同的 .NET 框架版本,只需替换v4.0.30319为适当的文件夹名称。
Hope this helps.
希望这可以帮助。
回答by GIOESCOM
回答by Jon
On Windows 8.1, IIS 8.5 the solution for me was to register 4.5 from the control panel:
在 Windows 8.1、IIS 8.5 上,我的解决方案是从控制面板注册 4.5:
Programs and Features > Turn Windows features on or off > Information Information Services > World Wide Web Services > Application Development Features > Select ASP.NET 4.5
程序和功能 > 打开或关闭 Windows 功能 > 信息信息服务 > 万维网服务 > 应用程序开发功能 > 选择 ASP.NET 4.5
Click OK.
单击确定。
回答by Taras Alenin
As the error idnicates - "This happens when the section is locked at a parent level". To unlock the section you can use appcmd.exeand execute the following command:
正如错误所指出的 - “当该部分被锁定在父级别时会发生这种情况”。要解锁该部分,您可以使用appcmd.exe并执行以下命令:
%windir%\system32\inetsrv\appcmd.exe unlock config -section:system.webServer/handlers -commitpath:apphost
For more information on about section locking and what a parent configuration context is refer to IIS documentation.
有关节锁定和父配置上下文的详细信息,请参阅IIS 文档。
回答by Javier Livio
In our case, we struggled with this error for quite some days. It turns out that in control panel, programs, turn windows features on or off.
在我们的例子中,我们与这个错误斗争了好几天。事实证明,在控制面板,程序中,打开或关闭 Windows 功能。
We selected Internet Information Services, world wide web services, Application development features and there we check the set of features associated with our development environment. For example: ASP.NET 4.6. .NET Extensibility 4.6, etc.
我们选择了 Internet 信息服务、万维网服务、应用程序开发功能,并在那里检查了与我们的开发环境相关的一组功能。例如:ASP.NET 4.6。.NET 可扩展性 4.6 等。
It works!
有用!
回答by HasanG
In my case, there were rules for IIS URL Rewritemodule but I didn't have that module installed. You should check your web.config if there are any modules included but not installed.
就我而言,IIS URL Rewrite模块有规则,但我没有安装该模块。如果包含但未安装的任何模块,您应该检查您的 web.config。
回答by Chris
Try unlocking the relevant IIS (7.5) configuration settings at server level, as follows:
尝试在服务器级别解锁相关的IIS(7.5)配置设置,如下:
- Open IIS Manager
- Select the serverin the Connections pane
- Open Configuration Editorin the main pane
- In the Sections drop down, select the section to unlock, e.g. system.webServer > defaultPath
- Click Unlock Attributein the right pane
- Repeat for any other settings which you need to unlock
- Restart IIS (optional) - Select the server in the Conncetions pane, click Restart in the Actions pane
- 打开IIS 管理器
- 在“连接”窗格中选择服务器
- 在主窗格中打开配置编辑器
- 在部分下拉列表中,选择要解锁的部分,例如system.webServer > defaultPath
- 单击右侧窗格中的解锁属性
- 重复您需要解锁的任何其他设置
- 重新启动 IIS(可选) - 在 Conncetions 窗格中选择服务器,在 Actions 窗格中单击 Restart

