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

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

详细错误信息:

模块IIS Web核心

通知BeginRequest

处理人尚未确定

错误码0x80070021

配置错误该配置项不能在该路径下使用。当section被锁定在父级时,就会发生这种情况。锁定是默认的(overrideModeDefault="Deny"),或者由overrideMode="Deny"或遗留的allowOverride="false"的位置标记显式设置。

配置文件\?\C:\inetpub\wwwroot\APITeslin\web.config

配置来源:

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

当前回答

如果是windows 10,则以admin身份打开powershell并执行以下命令:

dism /online /enable-feature /all /featurename:IIS-ASPNET45

其他回答

这很有效,还节省了我的时间。HTTP错误500.19 -内部服务器错误0x80070021 (IIS 8.5)

检查IIS服务器是否安装了URL重写功能。 如果没有安装,请确保您的web。配置文件没有URL重写相关配置

<!-- Make sure don't have below config, if server have not installed url rewrite feature. -->
<rewrite>
  <rules>
    <rule name="Fail bad requests">
      <match url=".*"/> ...

有时我们从旧服务器复制配置,然后直接部署到全新的服务器,然后我们可能会遇到这样的500问题。

正如错误所指出的那样-“当段被锁定在父级时发生这种情况”。要解锁该部分,您可以使用appcmd.exe并执行以下命令:

%windir%\system32\inetsrv\appcmd.exe unlock config -section:system.webServer/handlers -commitpath:apphost

有关区段锁定和父配置上下文的更多信息,请参阅IIS文档。

尝试在服务器级别解锁相关的IIS(7.5)配置设置,如下所示:

打开IIS管理器 在Connections窗格中选择服务器 在主窗格中打开Configuration Editor 在Sections下拉菜单中,选择要解锁的section,例如system。webServer > defaultPath 在右侧窗格中单击“解锁属性” 重复其他需要解锁的设置 重新启动IIS(可选)-在“连接”窗格中选择服务器,在“操作”窗格中单击“重新启动”

得到了完全相同的错误,然后得到了这个问题。正如@SpaceBison在评论中提到的,这个答案描述了解决方案- https://stackoverflow.com/a/12867753/404099。我发现得太晚了,它漏了几步。这对我来说很管用:

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