iis - 通过 Azure Pipelines 将 .NET Core Web 应用程序部署到 IIS 服务器时出现 500 错误
问题描述
我正在使用我的项目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
浏览器上只有一个。
我在 Startup.cs 或 Program.cs 中是否遗漏了任何代码?我将它们保留为默认值。
解决方案
要在 IIS 后面运行 ASP.NET Core 应用程序,您需要先安装托管包。
该捆绑包安装 .NET Core 运行时、.NET Core 库和 ASP.NET Core 模块。该模块允许 ASP.NET Core 应用程序在 IIS 后面运行。
在这里下载:
https://www.microsoft.com/net/permalink/dotnetcore-current-windows-runtime-bundle-installer
更多信息,参考:
安装此托管包后,尝试运行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 访问它。
推荐阅读
- python - 寻找多个变量和目标值之间的相关性
- c# - C#:底层连接已关闭,发送时发生意外错误
- python-3.x - BaseHTTPRequestHandler cgi.parse_multipart 永远不会返回
- python - 无法重新分配python全局变量
- flutter - Flutter pub get 执行时间过长
- java - Spring Data Mongo:使用非简单键持久化地图
- elasticsearch - 弹性搜索中的排序聚合?
- javascript - 在对象数组中提取具有相同键的非重复值
- cassandra - 具有非规范化的 cassandra 数据建模
- python - Form_valid 中的多对多