asp.net-core - .Net Core AspNetCoreHostingModel 是什么意思?

标签 asp.net-core .net-core

通过此链接,您可以了解 ASP.NET Core 模块

To configure an app for in-process hosting, add the property to the app's project file with a value of InProcess (out-of-process hosting is set with OutOfProcess)

读了好几遍了,还是不明白什么意思?

什么时候必须使用 OutOfProcess,什么时候必须使用 InProcess?

这些模型的优缺点?

做决定时依据什么?

最佳答案

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

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

OutOfProcess: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="InProcess">
        <environmentVariables />
      </aspNetCore>
    </system.webServer>
  </location>
</configuration>

对于进程外:

<?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 配置,它决定应用程序如何在本地运行,默认为 InProcess

关于asp.net-core - .Net Core AspNetCoreHostingModel 是什么意思?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55762322/

相关文章:

asp.net-core - Blazor 布局中的顶部菜单

jquery - Asp.net core 将数据绑定(bind)到按钮

c# - 通过外部(自定义)服务的 ASP 核心登录

.net-core - .NET 核心 SqlException :an error occurred during the pre-login handshake

c# - 为什么代码行为在发布和 Debug模式下不同?

c# - HttpClientFactory - 通过名称获取命名的类型化客户端

asp.net - http 服务器的责任与使用此服务器托管的 Web 应用程序的责任

asp.net-core - 迁移到 Stimulsoft Core

javascript - windows.location = url 破坏 MVC 绑定(bind)

c# - 在不使用 RouteAttribute 的情况下使用 ApiControllerAttribute