我正在尝试将一个asp.net core v3应用程序发布到IIS中运行。我创建了一个虚拟目录,并将其转换为应用程序。它有自己的IIS应用程序池,该池已设置为CLR:无托管代码、32位:False和Pipeline:集成。将应用程序发布到目录中,会创建默认的web.config文件和所需的json文件,如预期所示。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=".\PatientPlace3.dll" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" hostingModel="inprocess" />
</system.webServer>
</location>
</configuration>
如果我进入我的网站物理目录并手动运行“dotnet .\myapp.dll”,我可以在5001端口上运行它而没有任何问题。我的客户端应用程序和API调用都可以正常工作。但是当我尝试在IIS下访问URL时,我得到了一个503错误,并在事件查看器中看到以下信息:Unable to locate application dependencies. Ensure that the versions of Microsoft.NetCore.App and Microsoft.AspNetCore.App targeted by the application are installed.
然后出现以下信息:
Could not find 'aspnetcorev2_inprocess.dll'. Exception message: Could not execute because the specified command or file was not found. Possible reasons for this include:
* You misspelled a built-in dotnet command. * You intended to execute a .NET Core program, but dotnet-.\PatientPlace3.dll does not exist. * You intended to run a global tool, but a dotnet-prefixed executable with this name could not be found on the PATH.
另一个线索是,第一次访问该URL时,IIS会为DefaultAppPool启动w3wp进程,而不是我的自定义CORE进程。我在所有Program Files\dotnet\shared[frameworkname][version]目录(2.1.8到3.0.0)中都有aspnetcorev2_inprocess.dll,并且已安装模块。我已尝试将该dll复制到我的应用程序目录中,并完全限定dotnet参数。
始终出现相同的错误。