我在使用Visual Studio 2015开发了一个ASP.NET Core版本1.0.1的Web API。当我将该Web API发布到同一台PC上的IIS 10中时,一切都能正常工作。但是,当我将Web API的发布文件夹复制到另一台PC上时,浏览器会显示错误500.19 Internal Server Error,错误代码为0x8007000d,“由于页面相关的配置数据无效,所以无法访问请求的页面”,这表明web.config存在某些问题。我认为IIS版本不是问题所在,因为从IIS 10迁移到IIS 8或从IIS 8迁移到IIS 10都会出现相同的错误,并且在两台安装IIS 10的PC之间也会出现相同的错误。我已经查看了许多相关问题,例如The element 'system.webServer' has invalid child element 'aspNetCore'和其他与web.config文件相关的问题,它们似乎都能找到错误。开发环境中的web.config文件如下:
发布 Web API 后,web.config 文件如下所示:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<!--
Configure your application settings in appsettings.json. Learn more at http://go.microsoft.com/fwlink/?LinkId=786380
-->
<system.webServer>
<handlers>
<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModule" resourceType="Unspecified"/>
</handlers>
<aspNetCore processPath="%LAUNCHER_PATH%" arguments="%LAUNCHER_ARGS%" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" forwardWindowsAuthToken="false"/>
</system.webServer>
</configuration>
发布 Web API 后,web.config 文件如下所示:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<!--
Configure your application settings in appsettings.json. Learn more at http://go.microsoft.com/fwlink/?LinkId=786380
-->
<system.webServer>
<handlers>
<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModule" resourceType="Unspecified" />
</handlers>
<aspNetCore processPath="dotnet" arguments=".\buildingSecureWebApi.dll" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" forwardWindowsAuthToken="false" />
</system.webServer>
</configuration>
无论在哪台电脑上发布,此web.config文件内容相同。
关于我问题的解决方案,需要将Web API安装在任何版本的Windows上,但到目前为止,它只能在开发的计算机上正常工作。
stdoutLogEnabled="true"
可能有助于缩小问题范围。 - AperioOculusstdoutLogEnabled="true"
,但问题仍然存在。 - Mig