部署ASP.NET Core 2.0至IIS遇500错误0x8007000d,求排查web.config问题
Hey there, let's work through that frustrating 500 error with code 0x8007000d you're seeing when deploying your ASP.NET Core 2.0 app to IIS. As you noted, this error ties directly to invalid XML in either your Web.config or ApplicationHost.config file. Let's break down how to track down and fix the issue:
Step 1: Validate Your Truncated Web.config
First off, the Web.config snippet you shared cuts off mid-element (<add name="as...), which is already a red flag. XML is strict about properly closed tags and complete elements, so start here:
- Ensure the file is complete: Check that all opening tags (like
<configuration>,<system.webServer>,<handlers>) have matching closing tags (</handlers>,</system.webServer>,</configuration>). Missing closures are the most common culprit here. - Use an XML validator: Pop your full Web.config into Visual Studio's built-in XML editor (it highlights syntax errors in real-time) or a simple offline XML checker to catch typos, unquoted attributes, or malformed elements.
- Compare against a valid ASP.NET Core 2.0 Web.config: A standard working config looks like this—use it as a reference:
Double-check that your<?xml version="1.0" encoding="utf-8"?> <configuration> <system.webServer> <handlers> <add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModule" resourceType="Unspecified" /> </handlers> <aspNetCore processPath="dotnet" arguments=".\YourAppName.dll" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" /> </system.webServer> </configuration>aspNetCorenode has all required attributes and no syntax mistakes.
Step 2: Check ApplicationHost.config (If Web.config Looks Good)
If your Web.config checks out, move on to the server-level ApplicationHost.config (usually located at C:\Windows\System32\inetsrv\config):
- Look for your site's
<location>section specifically—sometimes inherited server configs have malformed XML elements. - Again, use an XML validator to scan the entire file for syntax errors.
Step 3: Enable Detailed Logs for Precise Error Details
To get a clearer picture of exactly where the XML is breaking, enable detailed logging in your Web.config:
<configuration> <system.webServer> <httpErrors errorMode="Detailed" /> <aspNetCore processPath="dotnet" arguments=".\YourAppName.dll" stdoutLogEnabled="true" stdoutLogFile=".\logs\stdout" /> </system.webServer> <system.web> <customErrors mode="Off" /> </system.web> </configuration>
After adding this, restart your IIS site, try accessing the app again, and check the logs folder (create it if it doesn't exist) for stdout logs. The detailed error page or log will tell you exactly which XML element is causing the problem.
Step 4: Verify ASP.NET Core Hosting Bundle Installation
While this error is XML-focused, it's worth confirming you have the ASP.NET Core 2.0 Runtime & Hosting Bundle installed on the IIS server. Missing this bundle can cause unexpected configuration errors, even if your XML looks correct.
If you can share your full, untruncated Web.config, I can help pinpoint the exact issue faster!
内容的提问来源于stack exchange,提问作者Santa Cloud

