我将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 Runtime,.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访问它。