如果在VS中正常运行,但是发布到服务器,使用IIS浏览后提示404,先做以下检查:
1、检查服务器是否已安装.NET Core,如果没有,从这里选择安装:
https://www.microsoft.com/net/download/archives
2、查看IIS - 模块,是否存在"AspNetCoreModule"模块,如果没有,从这里下载安装:
https://www.microsoft.com/net/permalink/dotnetcore-current-windows-runtime-bundle-installer
3、检查Web.config配置是否正确,应包括以下配置:
<configuration>
<location path="." inheritInChildApplications="false">
<system.webServer>
<handlers>
<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModuleV2" resourceType="Unspecified" />
</handlers>
<aspNetCore processPath="dotnet" arguments=".\webapi.dll" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" hostingModel="inprocess" />
</system.webServer>
</location>
</configuration>