简体   繁体   中英

Error 500.19 with 0x8007000d when running ASP.NET Core app in IIS despite AspNetCoreModule being installed

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.

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

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.

The HTML file contains this information:

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.

Detailed Error Information:

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

Note: in case it's not obvious from that message, this is a minimal repro of my problem, not the actual app

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:

安装了托管组件的添加删除程序的屏幕截图

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

IIS 中模块列表的屏幕截图

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.

Details:

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

站点模块错误的屏幕截图

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>

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>

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

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

HTTP Error 502.3 - Bad Gateway

There was a connection error while trying to route the request.

Detailed Error Information:

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

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

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>

What is causing IIS to fail to run this application?

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

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

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.

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.

Installing the .NET Core Hosting Bundle resolved the problem for me. Here is a link to the .NET Core Hosting Bundle.

Using .NET Core 3.1

I tried using the above suggestion, but didn't work. So, I reinstalled the Asp Net Core Runtime Hosting in Administrator Mode, and my ApplicationHost.Config got corrected.

If you install the .NET Core Windows Hosting Bundle , but the AspNetCoreModule still doesn't appear on your applicationHost.config , you can try to do what I did to solve my problem, after trying all the other solutions on SO and other places.

I found an applicationHost.config in another server that had those AspNetCoreModule lines and updated the file on the broken server. Not sure why they were not being added by the .NET Core installation.

I added the line below under the <globalModules> section:

<add name="AspNetCoreModule" image="%SystemRoot%\system32\inetsrv\aspnetcore.dll" />

And this one under <modules> :

<add name="AspNetCoreModule" />

Hope this helps.

Installing the .NET Core Hosting Bundle resolved the problem (like in answer upper)

In my case solution was simple, just restore Hosting bundle, and it helped. Before restore I get hresult 0x8007000d . In iis for net core applications, modules were not loaded.

一些图片了解更多信息

I also get this error on dotnet core 3.1.

After removing wrapper section from web.config application starts work:

在此处输入图片说明

Changed to:

<?xml version="1.0" encoding="UTF-8"?>
  <configuration>
     <system.webServer>
       <handlers>
          <add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModuleV2" resourceType="Unspecified" />
       </handlers>
       <aspNetCore processPath="dotnet" arguments=".\ContactForm.Microservice.dll" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" hostingModel="inprocess" />
     </system.webServer>
  </configuration>

In dot core 5.0, I solved this error by installing hosting bundle 5.0.13

https://dotnet.microsoft.com/en-us/download/dotnet/5.0

在此处输入图片说明

web.config

在此处输入图片说明

As you can see in the web.config, it uses module "AspNetCoreModuleV2" which i have marked yellow in the download page

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM