.Net Core AspNetCoreHostingModel是什么意思?

时间:2019-04-19 13:03:08

标签: asp.net-core .net-core

通过此链接,您可以阅读有关ASP.NET Core模块的信息

  

要为进程内托管配置应用程序,请将属性值添加到应用程序的项目文件中(值为OutProcess(通过OutOfProcess设置进程外托管))

我读过几次,但我不明白这是什么意思?

何时必须使用OutOfProcess,何时必须使用InProcess?

这些模型的优缺点?

做出决定时要依靠什么?

1 个答案:

答案 0 :(得分:2)

是指IIS如何托管您的应用程序(web.config)。

处理中 :IIS托管应用程序(w3wp.exe或iisexpress.exe)

OutOfProcess :Kenstrel托管应用程序,IIS是kestrel的代理。

更多details,有关如何配置以及使用时要记住的每个问题。

根据Microsoft,“ InProcess”具有明显更好的性能。

要配置 InProcess ,请添加以下内容的Web配置:

<?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="%LAUNCHER_PATH%" arguments="%LAUNCHER_ARGS%" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" hostingModel="OutOfProcess">
        <environmentVariables />
      </aspNetCore>
    </system.webServer>
  </location>
</configuration>

对于 OutOfProcess

<?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="%LAUNCHER_PATH%" arguments="%LAUNCHER_ARGS%" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" hostingModel="OutOfProcess">
        <environmentVariables />
      </aspNetCore>
    </system.webServer>
  </location>
</configuration>

在my-api文件夹中生成内部版本或使用以下方式将其发布到服务器时:

dotnet publish -o my-api -c release

请注意您的%LAUNCHER_PATH%和%LAUNCHER_ARGS%。

您最初提到的问题可能是关于.csproj配置,该配置决定了应用程序在本地运行的方式,默认为 OutOfProcess

相关问题