尽管已安装AspNetCoreModule,但在IIS中运行ASP.NET Core应用程序时出现0x8007000d错误500.19 [英] Error 500.19 with 0x8007000d when running ASP.NET Core app in IIS despite AspNetCoreModule being installed

查看:184
本文介绍了尽管已安装AspNetCoreModule,但在IIS中运行ASP.NET Core应用程序时出现0x8007000d错误500.19的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个ASP.NET Core应用程序,可以在IIS Express中很好地运行.同样,如果我通过dotnet run从命令行启动该应用程序,则一切都会顺利进行:

I have an ASP.NET Core app that runs great in IIS Express. Similarly, if I launch the app from the command line via dotnet run, everything works smoothly:

C:\Code\Sandbox\IisTestApp\IisTestApp>dotnet run
Using launch settings from C:\Code\Sandbox\IisTestApp\IisTestApp\Properties\launchSettings.json...
Hosting environment: Production
Content root path: C:\Code\Sandbox\IisTestApp\IisTestApp
Now listening on: http://localhost:5000
Now listening on: https://localhost:5001
Application started. Press Ctrl+C to shut down.

如果我尝试定位本地IIS,则会出现以下错误:

If I try to target local IIS, I get the following error:

无法启动进程C:\ Program Files \ dotnet \ dotnet.exe. Web服务器请求失败,状态码为500,内部服务器错误.完整的响应已写入C:\ Users {我的用户名} \ AppData \ Local \ Temp \ HttpFailure_08-05-50.html.

Unable to start process C:\Program Files\dotnet\dotnet.exe. The web server request failed with status code 500, Internal Server Error. The full response has been written to C:\Users{my user name}\AppData\Local\Temp\HttpFailure_08-05-50.html.

HTML文件包含以下信息:

The HTML file contains this information:

HTTP错误500.19-内部服务器错误

无法访问请求的页面,因为该页面的相关配置数据无效.

详细的错误信息:

模块 IIS Web核心
通知 BeginRequest
处理程序尚未确定
错误代码 0x8007000d
配置错误
配置文件 \?\ C:\ Code \ Sandbox \ IisTestApp \ IisTestApp \ web.config
请求的URL http://localhost:80/IisTestApp
物理路径 C:\ Code \ Sandbox \ IisTestApp \ IisTestApp
登录方式尚未确定
登录用户尚未确定

Module IIS Web Core
Notification BeginRequest
Handler Not yet determined
Error Code 0x8007000d
Config Error
Config File \?\C:\Code\Sandbox\IisTestApp\IisTestApp\web.config
Requested URL http://localhost:80/IisTestApp
Physical Path C:\Code\Sandbox\IisTestApp\IisTestApp
Logon Method Not yet determined
Logon User Not yet determined

注意:如果从该消息中看不出来,这是我问题的最小重现,而不是实际应用

我在网上看到的大多数内容都显示错误代码0x8007000d表示我没有.NET Core Windows Server Hosting组件(AspNetCoreModule),但我确实已经安装了该组件:

Most of what I see online says that the error code 0x8007000d indicates that I don't have the .NET Core Windows Server Hosting component (AspNetCoreModule), but I definitely have installed that:

我还可以在IIS的模块"主页面中看到它,并验证它指向的文件是否确实存在:

I can also see it in the main "Modules" page of IIS, and verified that the file it points to actually exists:

奇怪的是,如果我尝试转到该特定站点的模块"页面,则会收到与网页相同的错误消息:

Strangely, if I try to go to the Modules page for this specific site, I get the same error message as the web page:

执行此操作时出错.

There was an error while performing this operation.

详细信息:

文件名:\?\ C:\ Code \ Sandbox \ IisTestApp \ IisTestApp \ web.config
错误:

Filename: \?\C:\Code\Sandbox\IisTestApp\IisTestApp\web.config
Error:

此主机模块版本(2.1.8)通常与我安装的版本匹配:

This hosting module version (2.1.8) matches generally what I have installed:

C:\Users\{my user name}>dotnet --list-sdks
2.1.202 [C:\Program Files\dotnet\sdk]
2.1.504 [C:\Program Files\dotnet\sdk]

C:\Users\{my user name}>dotnet --list-runtimes
Microsoft.AspNetCore.All 2.1.4 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
Microsoft.AspNetCore.All 2.1.8 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
Microsoft.AspNetCore.App 2.1.4 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 2.1.8 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.NETCore.App 2.0.9 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 2.1.8 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]

我的测试应用程序的目标是:

And what my test app is targeting:

<Project Sdk="Microsoft.NET.Sdk.Web">

  <PropertyGroup>
    <TargetFramework>netcoreapp2.1</TargetFramework>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="Microsoft.AspNetCore.App" />
    <PackageReference Include="Microsoft.AspNetCore.Razor.Design" Version="2.1.2" PrivateAssets="All" />
  </ItemGroup>

</Project>

尽管如此,我认为问题确实与IIS和该托管组件有关!这是使用项目模板生成的(非常默认)web.config:

Despite all that, I think the problem really is related to IIS and that hosting component! Here is the (very default) web.config that is generated with the project template:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <location path="." inheritInChildApplications="false">
    <system.webServer>
      <handlers>
        <add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModule" resourceType="Unspecified" />
      </handlers>
      <aspNetCore processPath="bin\IISSupport\VSIISExeLauncher.exe" arguments="-argFile IISExeLauncherArgs.txt" stdoutLogEnabled="false">
        <environmentVariables />
      </aspNetCore>
    </system.webServer>
  </location>
</configuration>

注意:如果我在processPath中硬编码完整路径,或使用.\相对路径

Note: I still get the same error message if I hardcode the full path in the processPath, or use .\ relative pathing

如果删除<aspNetCore>节点,则会收到其他错误:

If I remove the <aspNetCore> node, I get a different error:

HTTP错误502.3-错误的网关

尝试路由请求时出现连接错误.

详细的错误信息:

模块 AspNetCoreModule
通知 ExecuteRequestHandler
处理程序 aspNetCore
错误代码 0x80070490
请求的URL http://localhost:80/IisTestApp
物理路径 C:\ Code \ Sandbox \ IisTestApp \ IisTestApp
登录方法匿名
登录用户匿名

Module AspNetCoreModule
Notification ExecuteRequestHandler
Handler aspNetCore
Error Code 0x80070490
Requested URL http://localhost:80/IisTestApp
Physical Path C:\Code\Sandbox\IisTestApp\IisTestApp
Logon Method Anonymous
Logon User Anonymous

关键是AspNetCoreModule这次抛出错误,因此它正在加载 并运行一些代码.

The point being that the AspNetCoreModule throws the error this time, so it is being loaded and running some code.

发布到单独的文件夹并在IIS中手动设置站点(而不是依靠默认的Visual Studio行为来创建指向"bin"文件夹的IIS网站)会导致相同的错误消息,尽管我得到了生成的web.config文件中的aspNetCore节点稍有不同:

Publishing to a separate folder and manually setting up the site in IIS (rather than relying on the default Visual Studio behavior of create an IIS website pointed at the "bin" folder) results in the same error message, although I get a slightly different aspNetCore node in the generated web.config file:

<aspNetCore processPath="dotnet" arguments=".\IisTestApp.dll" stdoutLogEnabled="true" stdoutLogFile=".\logs\stdout">
  <environmentVariables />
</aspNetCore>

是什么原因导致IIS无法运行此应用程序?

我尝试重新安装.NET Core(SDK,运行时和托管组件),但没有帮助.

I have tried re-installing .NET Core (SDK, runtime, and hosting component) but it did not help.

我还注意到有几篇文章提到安装IIS的URL重写模块可纠正此错误(特别是:

I also noticed several posts that mention installing the URL Rewrite module for IIS corrects this error (notably this: HTTP Error 500.19 - IIS 7.5 Error 0x8007000d). My web.config doesn't mention that module, but I tried installing it in case the AspNetCoreModule uses it under the covers. This did not help in my situation.

推荐答案

已排除了我(以及许多有用的评论者,尤其是

Having ruled out everything app-specific that I (and the many helpful commenters, especially Daboul) could think of, and having reviewed the visible IIS settings, I resorted to looking at the primary configuration file for IIS as a whole: applicationHost.config

每个简介到ApplicationHost.config ,此文件位于%windir%\system32\inetsrv\config中.由于实际的应用程序在我办公室的另一台计算机上工作,因此我使用diff程序对它们进行了比较,发现我的配置文件中缺少以下节点:

Per Introduction to ApplicationHost.config, this file is located in %windir%\system32\inetsrv\config. Since the real application is working on a different machine at my office, I compared them using a diff program, and found that the following node was missing from my configuration file:

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <configSections>
        <!-- ...lots of other stuff... -->
        <sectionGroup name="system.webServer">
            <!-- ...lots of other stuff... -->

            <!--This "section" node for aspNetCore is the one that was missing-->
            <section name="aspNetCore" overrideModeDefault="Allow" />

添加一个节点即可解决该错误.

Adding that one node resolved the error.

奇怪的是,文件中后来多次引用了AspNetCoreModule本身.由于我以前没有手动编辑过此文件,因此初次安装AspNetCoreModule时似乎出现了某种安装错误.

Oddly enough, the AspNetCoreModule itself is referenced multiple times later in the file. Since I haven't manually edited this file before, it seems possible that this was some kind of installation error when installing the AspNetCoreModule the first time.

这篇关于尽管已安装AspNetCoreModule,但在IIS中运行ASP.NET Core应用程序时出现0x8007000d错误500.19的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆