【问题标题】:ASP.NET Core 3.1 app straight out of the box runs in VS 2019 but not from iis. Getting HTTP Error 500.19 0x8007000d开箱即用的 ASP.NET Core 3.1 应用程序可在 VS 2019 中运行,但不能从 iis 中运行。获取 HTTP 错误 500.19 0x8007000d
【发布时间】:2022-02-22 01:38:47
【问题描述】:

我正在发布一个没有内容(即直接开箱即用)的 ASP.NET Core 3.1 Web 应用程序,并且在尝试运行网站时出现标题错误。

我在“发布”中使用文件夹配置文件选项。

不寻常的是已发布文件夹的内容 - 文件夹是:

cs  de  es; 

等包括

wwwroot;  zh-hans;  zh-hant;  appsettings.development.json 
appsettings.json 
Microsoft.AspNetCore.Mvc.Razor.Extensions.dll 
Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation.dll 
Microsoft.AspNetCore.Razor.Language.dll 
Microsoft.CodeAnalysis.CSharp.dll 
Microsoft.CodeAnalysis.dll 
Microsoft.CodeAnalysis.Razor.dll 
Microsoft.Extensions.DependencyModel.dll 
System.Text.Json.dll 
web.config 
WebTest.deps.json 
WebTest.dll 
WebTest.exe 
WebTest.pdb 
WebTest.runtimeconfig.json 
WebTest.Views.dll 
WebTest.Views.pdb

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="dotnet" arguments=".\WebTest.dll" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" hostingModel="inprocess" />
    </system.webServer>
  </location>
</configuration>
!--ProjectGuid: FAD94D81-0B07-4B20-8215-9AD183B65D61--

我尝试了各种选项更改,但没有任何效果。

任何帮助将不胜感激,谢谢

进一步了解您的 cmets: 从 IIS 管理器运行错误是: * HTTP 错误 500.19 - 内部服务器错误 请求的页面无法访问,因为该页面的相关配置数据无效。 错误代码 0x8007000d 配置错误
* 再次发布: 设置 target = win-x64 而不是 Portable 自成体系

* 我按照建议运行了 dotnet webtest.dll 并没有出现明显的错误。 再次从 IIS 管理器运行并得到同样的错误!

C:\Temp\WebDemos\AnnaMayTestFolder>dotnet webtest.dll
dbug: Microsoft.Extensions.Hosting.Internal.Host[1]
      Hosting starting
info: Microsoft.AspNetCore.DataProtection.KeyManagement.XmlKeyManager[0]
      User profile is available. Using 'C:\Users\bill\AppData\Local\ASP.NET\DataProtection-Keys' as key repository and Windows DPAPI to encrypt keys at rest.
dbug: Microsoft.AspNetCore.DataProtection.Repositories.FileSystemXmlRepository[37]
      Reading data from file 'C:\Users\bill\AppData\Local\ASP.NET\DataProtection-Keys\key-5f27c4fc-fa29-4712-a66e-a5c00fd8c31c.xml'.
dbug: Microsoft.AspNetCore.DataProtection.Repositories.FileSystemXmlRepository[37]
      Reading data from file 'C:\Users\bill\AppData\Local\ASP.NET\DataProtection-Keys\key-a07760bd-83a7-4ff1-963d-370c2bbee546.xml'.
dbug: Microsoft.AspNetCore.DataProtection.KeyManagement.XmlKeyManager[18]
      Found key {5f27c4fc-fa29-4712-a66e-a5c00fd8c31c}.
dbug: Microsoft.AspNetCore.DataProtection.KeyManagement.XmlKeyManager[18]
      Found key {a07760bd-83a7-4ff1-963d-370c2bbee546}.
dbug: Microsoft.AspNetCore.DataProtection.KeyManagement.DefaultKeyResolver[13]
      Considering key {a07760bd-83a7-4ff1-963d-370c2bbee546} with expiration date 2020-09-05 18:58:12Z as default key.
dbug: Microsoft.AspNetCore.DataProtection.TypeForwardingActivator[0]
      Forwarded activator type request from Microsoft.AspNetCore.DataProtection.XmlEncryption.DpapiXmlDecryptor, Microsoft.AspNetCore.DataProtection, Version=3.1.4.0, Culture=neutral, PublicKeyToken=adb9793829ddae60 to Microsoft.AspNetCore.DataProtection.XmlEncryption.DpapiXmlDecryptor, Microsoft.AspNetCore.DataProtection, Culture=neutral, PublicKeyToken=adb9793829ddae60
dbug: Microsoft.AspNetCore.DataProtection.XmlEncryption.DpapiXmlDecryptor[51]
      Decrypting secret element using Windows DPAPI.
dbug: Microsoft.AspNetCore.DataProtection.TypeForwardingActivator[0]
      Forwarded activator type request from Microsoft.AspNetCore.DataProtection.AuthenticatedEncryption.ConfigurationModel.AuthenticatedEncryptorDescriptorDeserializer, Microsoft.AspNetCore.DataProtection, Version=3.1.4.0, Culture=neutral, PublicKeyToken=adb9793829ddae60 to Microsoft.AspNetCore.DataProtection.AuthenticatedEncryption.ConfigurationModel.AuthenticatedEncryptorDescriptorDeserializer, Microsoft.AspNetCore.DataProtection, Culture=neutral, PublicKeyToken=adb9793829ddae60
dbug: Microsoft.AspNetCore.DataProtection.AuthenticatedEncryption.CngCbcAuthenticatedEncryptorFactory[4]
      Opening CNG algorithm 'AES' from provider '(null)' with chaining mode CBC.
dbug: Microsoft.AspNetCore.DataProtection.AuthenticatedEncryption.CngCbcAuthenticatedEncryptorFactory[3]
      Opening CNG algorithm 'SHA256' from provider '(null)' with HMAC.
dbug: Microsoft.AspNetCore.DataProtection.KeyManagement.KeyRingProvider[2]
      Using key {a07760bd-83a7-4ff1-963d-370c2bbee546} as the default key.
dbug: Microsoft.AspNetCore.DataProtection.Internal.DataProtectionHostedService[0]
      Key ring with default key {a07760bd-83a7-4ff1-963d-370c2bbee546} was loaded during application startup.
dbug: Microsoft.AspNetCore.Server.Kestrel.Core.KestrelServer[2]
      Failed to locate the development https certificate at '(null)'.
dbug: Microsoft.AspNetCore.Server.Kestrel.Core.KestrelServer[0]
      Using development certificate: CN=localhost (Thumbprint: 5D0B4342CC4EAD5ED23E1752F64EC374F9EE941C)
dbug: Microsoft.AspNetCore.Server.Kestrel[0]
      No listening endpoints were configured. Binding to http://localhost:5000 and https://localhost:5001 by default.
info: Microsoft.Hosting.Lifetime[0]
      Now listening on: http://localhost:5000
info: Microsoft.Hosting.Lifetime[0]
      Now listening on: https://localhost:5001
dbug: Microsoft.AspNetCore.Hosting.Diagnostics[0]
      Loaded hosting startup assembly WebTest
info: Microsoft.Hosting.Lifetime[0]
      Application started. Press Ctrl+C to shut down.

信息:Microsoft.Hosting.Lifetime[0] 托管环境:生产 信息:Microsoft.Hosting.Lifetime[0] 内容根路径:C:\Temp\WebDemos\AnnaMayTestFolder dbug:Microsoft.Extensions.Hosting.Internal.Host[2] 托管开始

* 任何人都可以确认上面显示的 Publish Target 输出文件夹结构是典型的吗?在我看来完全错误!典型的已发布文件夹会是什么样子?这是我第一次尝试建立一个网站。

在这个问题上尽我所能进行研究后,我现在完全被难住了。如果有人可以进一步提供帮助,那就太好了。

【问题讨论】:

  • 我已经检查了应用程序和 iis 应用程序池中的位数;用户/系统/等的文件夹安全访问。现在在黑暗中跌跌撞撞!
  • 从控制台运行应用程序并检查错误。更改appsettings.json内的LogLevel
  • 添加错误,没有它我们无法知道发生了什么。
  • 看看你是否安装了.net core 3.1 sdk。有一次我没有在服务器上安装正确的 sdk。
  • 从 IIS 运行管理错误是: * HTTP 错误 500.19 - 内部服务器错误 请求的页面无法访问,因为该页面的相关配置数据无效。错误代码 0x8007000d 配置错误 * 再次发布:set target = win-x64 而不是 Portable Self-contained * 我按照建议运行了 dotnet webtest.dll(请参阅下一条评论)并且没有明显错误。再次从 IIS 管理器运行并得到同样的错误!

标签: c# asp.net-core


【解决方案1】:

正如 Max 所说,使用服务器上的命令提示符或 powershell 从其目录运行 dotnet WebTest.dll。这应该会给你一个更详细的问题解释。如果您没有将应用程序发布为独立的,那么您需要安装服务器托管包 (https://docs.microsoft.com/en-us/aspnet/core/host-and-deploy/iis/?view=aspnetcore-3.1#install-the-net-core-hosting-bundle),如果您还没有这样做的话。

【讨论】:

    【解决方案2】:

    上面显示的发布目标输出文件夹结构是典型的。

    在 IIS(本地或远程)上部署应用时,请确保您的目标文件夹具有以下安全权限:

    【讨论】:

    • 我尝试将完全控制权授予 IIS IUSRS 和 IIS IUSRS (MyMachine\IIS_IUSRS),但没有任何区别。
    • @PatMcGowan 看看docs.microsoft.com/en-us/iis/extensions/using-iis-express/… IIS 中默认不允许某些 HTTP 端口
    • @Mohammand Barbast 只是为了清楚。我可以使用 IIS Express 从 Visual Studio 内部运行该网站,一切正常。但是,在将网站发布到本地文件夹后,我尝试从 IIS 管理器中运行网站并得到上述错误。您认为发布到服务器值得一试吗?我可以接受这样做的成本,如果它有效,那没关系。
    • @PatMcGowan 也许是因为你的 HTTP 端口。我在某处看到默认情况下我们被允许使用 44300-44399 端口范围作为我们的应用程序 SSL 端口。在 Google 上搜索更多信息。
    • @PatMcGowan 我记得我遇到了和你一样的问题,这与端口配置有关。
    【解决方案3】:

    从 IIS 管理器运行错误是:* HTTP 错误 500.19 - 内部服务器 错误 无法访问请求的页面,因为该页面的相关配置数据无效。错误代码 0x8007000d 配置错误

    如果您仍然遇到此问题: 请在modules on IIS manager 中确认 IIS 正在为此站点加载 AspNetCoreModuleV2 您还可以在 IIS 中 enable failed request tracing 确认请求到达 ANCM 或在此之前以某种方式失败。

    Visual Studio 可以通过运行 .net 核心 kestrel 服务器应用程序的帮助应用程序启动这些站点,但“独立”已发布站点需要安装 ASP.net core hosting bundle 才能获取“AspNetCoreModule”(链接提供“托管捆绑安装程序”以及检查 ANCM dll 是否存在的步骤)。

    与其他缺少的模块一样,如果 IIS 无法解析它无法识别的 web.config 部分,则 IIS 会指示“配置错误”,也许就是这种情况。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-08-18
      • 1970-01-01
      • 2020-12-23
      • 2021-08-26
      • 1970-01-01
      • 2016-12-13
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多