iis Azure上的.NET核心3.1网站:500.37 ANCM无法在启动时间限制内启动

zbdgwd5y  于 2022-12-13  发布在  .NET
关注(0)|答案(3)|浏览(587)

我有部署在Azure Web应用程序服务中的.NET Core 3.1 API。我在Azure中运行应用程序时遇到问题,因为错误500.37 ANCM无法在启动时间限制内启动。我通过增加web.config中的startupTimeLimit(如下所示)设法解决了此问题。
但是现在,当我在Azure Web应用服务中运行2个示例时,其中一个示例工作正常,但另一个仍然有相同的错误。
如何在IIS中为多个示例设置startupTimeLimit?

网页配置

  1. <?xml version="1.0" encoding="utf-8"?>
  2. <configuration>
  3. <!-- To customize the asp.net core module uncomment and edit the following section.
  4. For more info see https://go.microsoft.com/fwlink/?linkid=838655 -->
  5. <system.webServer>
  6. <httpProtocol>
  7. <customHeaders>
  8. <remove name="X-Powered-By" />
  9. </customHeaders>
  10. </httpProtocol>
  11. <handlers>
  12. <add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModuleV2" resourceType="Unspecified" />
  13. </handlers>
  14. <aspNetCore processPath="dotnet" arguments=".\Clients.Api.dll" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" startupTimeLimit="180" hostingModel="inprocess" >
  15. </aspNetCore>
  16. </system.webServer>
  17. </configuration>

编辑:

我使用azure web app Scale out (App Service plan)将正在运行的示例增加到2。

nzkunb0c

nzkunb0c1#

我们通过将startupTimeLimit增加到300来解决此解决方案

  1. <?xml version="1.0"?>
  2. <configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
  3. <location>
  4. <system.webServer>
  5. <aspNetCore xdt:Transform="SetAttributes(startupTimeLimit)" startupTimeLimit="300">
  6. </aspNetCore>
  7. </system.webServer>
  8. </location>
  9. </configuration>
uqdfh47h

uqdfh47h2#

最后我能够修复这个错误。
这是一个配置错误(.net核心配置)。当项目在.net核心3.1中时,Azure应用服务需要项目的其他配置。解决方案是:

  • 在项目文件(ASP.NET或Web API项目)(*.proj)中,必须将以下行放在TargetFramework的正下方:

<AspNetCoreHostingModel>OutOfProcess</AspNetCoreHostingModel>
最终的 *.proj文件将如下所示:

  1. <Project Sdk="Microsoft.NET.Sdk.Web"> <PropertyGroup>
  2. <TargetFramework>netcoreapp3.1</TargetFramework>
  3. <AspNetCoreHostingModel>OutOfProcess</AspNetCoreHostingModel>
  4. <UserSecretsId>my-secrets-go-here</UserSecretsId>
  5. <Version>1.1.0.0</Version>
  6. <Authors>me</Authors>
  7. <Company>TheCompany</Company>
  8. <Platforms>AnyCPU;x64</Platforms>
  9. </PropertyGroup>
  10. ...
  11. </Project>

添加这些更改并在Azure应用服务上上传新版本后,应用将无错误地执行(除非有其他与您的代码相关的内容)。
我能够通过从本地直接在IIS上执行我的项目来复制此错误,当您执行此操作时,VS将打开Web浏览器,但Web页面从未加载。

展开查看全部
lkaoscv7

lkaoscv73#

如果应用程序在开发计算机上运行正常,而此错误存在于***未连接到Internet***生产服务器上
检查事件日志,查找是否有类似以下错误:

从自动更新cab中提取第三方根目录列表失败

您只需要更新服务器证书
1.使用联机选项:将服务器连接到互联网
1.使用“脱机”选项:follow this guide

相关问题