.NetCore 发布到IIS中使用遇到的问题

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,再次浏览,成功,噢,耶斯✌

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值