请求协助排查.NET Core Web API的HTTP Error 500.19错误
Hey there, let's work through this annoying 500.19 error you're hitting. That specific error code (0x8007000d) almost always means IIS can't parse your web.config file—either because it's malformed, has unrecognized settings, or the server lacks the right tools to handle .NET Core apps. Here's how to fix it step by step:
1. Double-check your web.config syntax
First, crack open C:\inetpub\wwwroot\webapi\web.config and scan for obvious issues:
- Missing closing tags (like a forgotten
</>for a configuration section) - Typos in section names or attributes
- Configuration sections that IIS doesn't recognize (common if you copied settings from a non-IIS environment)
For a standard .NET Core Web API, your system.webServer section should look something like this—make sure yours matches (swap YourApi.dll with your actual assembly name):
<system.webServer> <handlers> <add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModuleV2" resourceType="Unspecified" /> </handlers> <aspNetCore processPath="dotnet" arguments=".\YourApi.dll" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" hostingModel="inprocess" /> </system.webServer>
2. Install the ASP.NET Core Hosting Bundle
This is the most common fix. IIS needs the AspNetCoreModuleV2 to run .NET Core apps, and it's included in the ASP.NET Core Hosting Bundle.
- Install the bundle (match it to your .NET Core version)
- After installation, restart IIS by running
iisresetin Command Prompt or PowerShell - Try accessing your API again
3. Verify folder permissions
IIS's application pool identity needs read access to your API's directory. Here's how to set it:
- Right-click
C:\inetpub\wwwroot\webapi→ Properties → Security tab - Click Edit → Add
- Enter your app pool name (usually
IIS AppPool\[YourAppPoolName]) and click Check Names to confirm - Grant the identity Read & Execute, List folder contents, and Read permissions
- Click OK to save changes
4. Match .NET Core runtime versions
Make sure the server has the exact .NET Core runtime version your API was built for. To check installed runtimes on the server:
dotnet --list-runtimes
If the version doesn't match, either:
- Update the server's .NET Core runtime to match your project's target version
- Or adjust your project's target framework to match the server's installed runtime, then re-publish
5. Enable detailed logging for deeper insights
If the above steps don't work, turn on stdout logging to get more details about what's failing:
- Edit your
web.configand setstdoutLogEnabled="true"in the<aspNetCore>section - Create a
logsfolder in your API directory (if it doesn't exist) - Access your API again, then check the log files in
C:\inetpub\wwwroot\webapi\logs—they'll have specific error messages to point you to the root cause
内容的提问来源于stack exchange,提问作者mehrannva

