Fork me on GitHub
代码改变世界

IIS 部署 .NET8/7/6/5

2024-10-31 20:54  沉睡的木木夕  阅读(69)  评论(0编辑  收藏  举报

以我公司所在的测试服务器为例:windows server2012、IIS 7
部署 .NET8 程序不出意外会报这个错:

The specified version of Microsoft.NetCore.App or Microsoft.AspNetCore.App was not found. 

这是因为服务器没有安装Hosting Bundle

在安装完 Hosting Bundle 之后,可能还会报如下错误:

HTTP Error 500.30 - ASP.NET Core app failed to start 

Common solutions to this issue: 
•The app failed to start
•The app started but then stopped
•The app started but threw an exception during startup

Troubleshooting steps: 
• Check the system event log for error messages 
• Enable logging the application process' stdout messages 
• Attach a debugger to the application process and inspect 

这是因为 webconfig 文件没有配置正确,更改 <aspNetCore processPath="dotnet" arguments=".\YourAppName.dll" stdoutLogEnabled="true" stdoutLogFile=".\logs\stdout" hostingModel="InProcess" /> 中的 InProcess 改成 OutOfProcess 即可(高版本服务器可能不需要)。
即完整的内容为:

<aspNetCore processPath="dotnet" arguments=".\YourAppName.dll" stdoutLogEnabled="true" stdoutLogFile=".\logs\stdout" hostingModel="OutOfProcess" />