Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
522 views
in Technique[技术] by (71.8m points)

c# - 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:CodeSandboxIisTestAppIisTestApp>dotnet run
Using launch settings from C:CodeSandboxIisTestAppIisTestAppPropertieslaunchSettings.json...
Hosting environment: Production
Content root path: C:CodeSandboxIisTestAppIisTestApp
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 Filesdotnetdotnet.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}AppDataLocalTempHttpFailure_08-05-50.html.

The HTML file contains this information:

Screenshot of 500.19 error

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:CodeSandboxIisTestAppIisTestAppweb.config
Requested URL http://localhost:80/IisTestApp
Physical Path C:CodeSandboxIisTestAppIisTestApp
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:

screenshot of add remove programs with hosting component installed

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

Screenshot of modules list in 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:CodeSandboxIisTestAppIisTestAppweb.config
Error:

Screenshot of site modules 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 Filesdotnetsdk]
2.1.504 [C:Program Filesdotnetsdk]

C:Users{my user name}>dotnet --list-runtimes
Microsoft.AspNetCore.All 2.1.4 [C:Program FilesdotnetsharedMicrosoft.AspNetCore.All]
Microsoft.AspNetCore.All 2.1.8 [C:Program FilesdotnetsharedMicrosoft.AspNetCore.All]
Microsoft.AspNetCore.App 2.1.4 [C:Program FilesdotnetsharedMicrosoft.AspNetCore.App]
Microsoft.AspNetCore.App 2.1.8 [C:Program FilesdotnetsharedMicrosoft.AspNetCore.App]
Microsoft.NETCore.App 2.0.9 [C:Program FilesdotnetsharedMicrosoft.NETCore.App]
Microsoft.NETCore.App 2.1.8 [C:Program FilesdotnetsharedMicrosoft.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="binIISSupportVSIISExeLauncher.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:CodeSandboxIisTestAppIisTestApp
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=".logsstdout">
  <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.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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%system32inetsrvconfig. 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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...