Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

.Net Core AspNetCoreHostingModel what does it mean?

By this link, you can read about ASP.NET Core Module

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)

I've read several times but I don't understand what it's mean?

When I must use OutOfProcess and when InProcess?

Pros and cons these models?

What to rely on when making a decision?

like image 880
Igor Cova Avatar asked Apr 19 '19 13:04

Igor Cova


1 Answers

Is referring to how IIS is hosting your app (web.config).

InProcess : IIS host the app (w3wp.exe or iisexpress.exe)

OutOfProcess: Kestrel host the app, IIS is a proxy to kestrel.

More details on how to configure and what to keep in mind for each one when using.

'InProcess' has significant better performance according to Microsoft.

To configure InProcess add web config with:

<?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>

For 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>

when you will generate the build in my-api folder or plain publish to your server with:

dotnet publish -o my-api -c release

will take care if your %LAUNCHER_PATH% and %LAUNCHER_ARGS%.

What you are referring in initial question possibly is about .csproj config that dictate how app runs locally, default is OutOfProcess

like image 124
SilentTremor Avatar answered Oct 13 '22 11:10

SilentTremor