【发布时间】:2022-01-14 23:56:34
【问题描述】:
我创建了一个 ASP.NET Core 5.0 Web API 项目。我可以在 IIS Express 中执行和运行应用程序。如果我部署应用程序,则会收到以下错误:
Server Error in Application "application name"
HTTP Error 500.19 – Internal Server Error
HRESULT: 0x8007000d
Description of HRESULT
The requested page cannot be accessed because the related configuration data for the page is invalid.
官方MS support page引用了两个原因:
出现此问题是因为 ApplicationHost.config 或 Web.config 文件包含格式错误或无法识别的 XML 元素。 IIS 不能 识别未安装的模块的 XML 元素。为了 例如,IIS URL 重写模块。
分辨率
使用以下方法之一:
Delete the malformed XML element from the ApplicationHost.config or Web.config file. Check the unidentified XML elements, and then install the relevant IIS modules.
我的 web.config 随我的构建/部署过程一起提供。对于配置,我使用 appsettings.json。所以我不知道我的 web.config 是否以及有什么可能发生变化。有什么建议吗?
...\inetpub\wwwroot\MyApi\web.config:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<location path="." inheritInChildApplications="false">
<system.webServer>
<handlers>
<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModuleV2" resourceType="Unspecified" />
</handlers>
<aspNetCore processPath="dotnet" arguments=".\MyApi.dll" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" hostingModel="inprocess" />
</system.webServer>
</location>
</configuration>
<!--ProjectGuid: f659debd-cac7-4ce5-b2fe-d1a440a87811-->
【问题讨论】:
标签: asp.net-core-webapi iis-10