1、.NetCore 配置了swagger发布到iis时,刷新网页出现404
原因:
在代码中限制ASPNETCORE_ENVIRONMENT为Production时关闭swagger。而发布后项目往往默认为Production环境,将其修改为Development即可解决。
解决:
打开web.config文件,添加
<environmentVariables> <environmentVariable name="ASPNETCORE_ENVIRONMENT" value="Development" /> </environmentVariables>
完整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=".\Blog.Core.exe" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" hostingModel="InProcess" > <environmentVariables> <environmentVariable name="ASPNETCORE_ENVIRONMENT" value="Development" /> </environmentVariables> </aspNetCore> </system.webServer> </location> </configuration>
浙公网安备 33010602011771号