通过Azure Pipelines将.NET Core Web App部署到IIS服务器时出现500错误

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

我将AzureDevOps用作项目的CI&CD工具。我使用了名为IIS website deployment的模板。我已经完成配置,并且运行良好。它可以成功部署。但是当我查看它时,只会得到500错误。

端口80(没有站点):

HTTP Error 500.19 - Internal Server Error

The requested page cannot be accessed because the related configuration data for the page is invalid.

端口8000(我部署了站点并打开了防火墙访问权限:我找不到500左右的页面,浏览器上只有ERR_EMPTY_RESPONSE

这里是构建代码的目标文件夹中的屏幕截图Screenshot

web.config.xmlweb.config.xml

我在Startup.cs或Program.cs中缺少任何代码吗?我将其保留为默认设置。

iis .net-core azure-devops azure-pipelines continuous-deployment
1个回答
0
投票

要在IIS后面运行ASP.NET Core应用,您需要先安装主机捆绑包。

该捆绑软件将安装.NET Core Runtime,.NET Core库和ASP.NET Core模块。该模块允许ASP.NET Core应用程序在IIS之后运行。

在这里下载:

https://www.microsoft.com/net/permalink/dotnetcore-current-windows-runtime-bundle-installer

有关更多信息,请参考:

https://docs.microsoft.com/en-us/aspnet/core/host-and-deploy/iis/?view=aspnetcore-3.1#install-the-net-core-hosting-bundle

安装此托管捆绑包后,请尝试运行dotnet ./yourdll.dll以测试.NET Core应用程序是否可以直接启动并准备处理HTTP请求。默认情况下,ASP.NET Core应用程序将启动并监听端口5000。

准备好应用程序后,将其部署到IIS文件夹中。像这样写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=".\YOUR_DLL.dll" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" hostingModel="inprocess" />
    </system.webServer>
  </location>
</configuration>

并尝试从IIS访问它。

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