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:
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:
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.