Core 2.0发布到IIS,web.config错误

问题描述 投票:0回答:1

使用Visual Studio 2019我已经发布了Core 2.0网站。

我可以从命令行正常运行网站:

c:\www>dotnet My.Site.Web.dll
Hosting environment: Production
Content root path: c:\www
Now listening on: http://localhost:5000
Now listening on: https://localhost:5001
Application started. Press Ctrl+C to shut down.

我可以使用端口5000在浏览器中加载站点而不会出现问题。

我还创建了一个指向c:\ www的IIS站点。应用程序池正在使用“无托管代码”。

我已安装以下组件:

  • Microsoft .NET Core 2.1.13-Windows Server托管
  • Microsoft .NET Core运行时2.1.13(x64)
  • Microsoft .NET Core运行时2.1.13(x86)
  • Visual Studio中的Microsoft .NET Core SDK 3.0.100(x64)

[如果尝试打开IIS站点,则会出现错误,“ HTTP错误500.19-内部服务器错误无法访问请求的页面,因为该页面的相关配置数据无效。配置文件\?\ C:\ www \ web.config“

它说的“配置源”是“ -1:0:“

几分钟前重新安装了主机捆绑包。

在IIS管理器中,当我打开网站并双击“ ASP”小部件时出现错误:

“执行此操作时出错。细节:文件名\?\ C:\ www \ web.config错误:“

我有一台具有相同网站,相同路径,Core运行时和SDK的开发机器,并且该网站在该机器上工作。我将工作站点复制到了无法运行的站点,但仍然无法解决问题。

似乎好像没有安装IIS主机捆绑包,但是我是在几分钟前安装的。

我的web.config是由Visual Studio生成的,看起来像这样:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <location path="." inheritInChildApplications="false">
    <system.webServer>

      <handlers>
        <add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModule" resourceType="Unspecified" />
      </handlers>

      <aspNetCore processPath="dotnet" arguments=".\My.Site.Web.dll" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" />
    </system.webServer>
  </location>
</configuration>
asp.net-core-2.1 iis-10
1个回答
0
投票

尽管已经安装了.NET Core Runtime 2.1.13,但我刚刚安装了.NET Core Runtime 3.0.0,它已经解决了问题。

[当我运行dotnet --info时,我部分看到了这一点:

Runtime Environment:
 Base Path:   C:\Program Files\dotnet\sdk\3.0.100\

因此,我猜测它出于某种原因要使用3.0运行时,并进行了安装。似乎有效。

© www.soinside.com 2019 - 2024. All rights reserved.