【问题标题】:How to config IIS to run .net core 2.2?如何配置 IIS 以运行 .net core 2.2?
【发布时间】:2019-06-11 19:53:45
【问题描述】:

1- 在 Visual Studio 2019 和 .net core 2.2 上,创建了一个默认 Web 应用程序,并且没有更改我的项目中的任何内容,只需发布​​它即可。

2- 从this link 安装相同版本的运行时并将发布文件夹放在 IIS(Windows 10 X64 企业版)的端口 5000 上。

3- 在 IIS 上将 CLR 版本更改为“无托管代码”并浏览网站,但我收到以下错误消息:

HTTP Error 500.19 - Internal Server Error
The requested page cannot be accessed because the related configuration data 
 for the page is invalid.

Detailed Error Information:
Module     IIS Web Core
Notification       Unknown
Handler    Not yet determined
Error Code     0x8007000d
Config Error       
Config File    \\?  \C:\WebApplication1\WebApplication1\bin\Release\netcoreapp2.2\publish\web.config
Requested URL      http://localhost:5000/
Physical Path      
Logon Method       Not yet determined
Logon User     Not yet determined

this link上查找此错误代码“错误代码0x8007000d”后,我不知道是什么问题。 我应该设置一个配置还是什么?

编辑: 此应用程序在 Visual Studio 上运行良好

【问题讨论】:

    标签: c# .net asp.net-mvc .net-core


    【解决方案1】:

    安装.NET Core 2.2 Runtime & Hosting Bundle for Windows 并刷新您的页面。该错误是因为您的 PC 中没有安装 AspNetCoreModule。

    您可以阅读有关 ASP.NET Core 模块here 的更多信息。

    【讨论】:

      【解决方案2】:

      要将 .net 核心应用程序托管到 IIS,以下是我设法解决的清单

      • 安装 .net core bundle(低于 2.2 v1)和(3.0 及高于 v2)
        • 有时 x86 和 x64 .net 核心版本可能会出现问题
          那时在 Visual Studio 中,即使安装了特定版本,您也无法选择 .net 核心版本
          • 为了解决这个问题,我通常卸载所有版本并使用 x64 版本的 .net 核心运行时
      • 重启iis"net stop was /y" 然后"net start w3svc"
      • 安装后检查 IIS 您可以看到 v1 和 v2 的模块
      • 创建应用程序池 没有托管 clr 版本(.net 核心应用程序)。供框架应用使用 (v4.0)
      • 在 program.cs 中使用“UseIISIntegration()”

      错误

      Application 'C:\TestCoreApp\' failed to start. Exception message:
      Could not find dotnet.exe at 'C:\TestCoreApp\dotnet.exe' or
      using the system PATH environment variable. Check that 
      a valid path to dotnet is on the PATH and 
      the bitness of dotnet matches the bitness of the IIS worker process.
      

      在 web 配置中更改 processPath="C:\Program Files\dotnet\dotnet.exe"processPath="dotnet.exe" 或添加 环境变量路径

      在 config.xml 中交叉检查

      <?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="C:\Program Files\dotnet\dotnet.exe" arguments=".\Webpi.test.dll" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" hostingModel="inprocess">
              <environmentVariables>
                <environmentVariable name="COMPLUS_ForceENC" value="1" />
                <environmentVariable name="ASPNETCORE_ENVIRONMENT" value="Development" />
              </environmentVariables>
            </aspNetCore>
          </system.webServer>
        </location>
      </configuration>
      

      错误:

      Unable to load 'C:\Program Files\dotnet\host\fxr\3.1.0\hostfxr.dll'. This might be caused by a bitness mismatch between IIS application pool and published application.
      

      解决方案

      在.net clr 版本中检查您的应用程序池是否有“无托管代码”在此处输入代码`

      【讨论】:

        猜你喜欢
        • 2020-12-23
        • 1970-01-01
        • 1970-01-01
        • 2020-03-13
        • 2019-07-08
        • 2020-01-27
        • 2019-09-20
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多