.Net核心AspNetCoreHostingModel是什么意思?

问题描述 投票:0回答:1

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

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

我读了几遍,但我不明白这是什么意思?

什么时候我必须使用OutOfProcess和InProcess?

这些模型有利有弊吗?

做出决定时要依赖什么?

asp.net-core .net-core
1个回答
2
投票

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

InProcess:IIS托管应用程序(w3wp.exe或iisexpress.exe)

Out Of Process:Kestrel托管应用程序,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

© www.soinside.com 2019 - 2024. All rights reserved.