1。最开始添加到IIS中,浏览页面时,页面提示\\?\X:\publish\web.config无法找到
解决方法:1)确保C:\Windows\System32\inetsrv文件夹中aspnetcore.dll
2)修改C:\Windows\System32\inetsrv\config文件夹中的applicationHost.config
修改内容如下,保存后重启下IIS
<configSections>
<sectionGroup name="system.webServer">
<!--add-->
<section name="aspNetCore" overrideModeDefault="Allow" />
<!--add-->
</sectionGroup name="system.webServer">
</configSections>
<globalModules>
<!--add-->
<add name="AspNetCoreModule" image="%SystemRoot%\system32\inetsrv\aspnetcore.dll" />
<!--add-->
</globalModules>
<location>
<system.webServer>
<modules>
<!--add-->
<add name="AspNetCoreModule" />
<!--add-->
</modules>
</system.webServer>
</location>
2.接着重启IIS后,再浏览项目时,报错
Service Unavailable -------- HTTP Error 503.The service is unavailable
IIS应用池也会停止掉。尝试过普通程序,也是同样情况。
从这里开始,一直在这个坑里转了一天( ╯□╰ )
网上百度后,安装了VC_redist,还有aspnetcore-runtime,但是还有同样的问题。
后来想起查看windows日志,错误信息如下,无法加载模块 DLL“C:\WINDOWS\system32\inetsrv\aspnetcore.dll”。
查询之后发现还少安装了dotnet-hosting,下载地址:https://dotnet.microsoft.com/download/dotnet-core/thank-you/runtime-aspnetcore-3.1.2-windows-hosting-bundle-installer
安装之后,还是有问题
继续网上找答案,最后发现了有用的,将之前的配置文件再稍微修改下,改动如下
<configSections>
<sectionGroup name="system.webServer">
<!--add-->
<section name="aspNetCore" overrideModeDefault="Allow" />
<!--add-->
</sectionGroup name="system.webServer">
</configSections>
<globalModules>
<!--add-->
<add name="AspNetCoreModule" image="%SystemRoot%\system32\inetsrv\aspnetcore.dll"
preCondition="integratedMode,runtimeVersionv4.0,bitness64"/>
<!--add-->
</globalModules>
<location>
<system.webServer>
<modules>
<!--add-->
<add name="AspNetCoreModule"
preCondition="integratedMode,runtimeVersionv4.0,bitness64"/>
<!--add-->
</modules>
</system.webServer>
</location>
保存,重启IIS,再次浏览,成功,噢,耶斯✌