Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MVC Core - What is the difference between UseIIS and UseIISIntegration

Tags:

Looking at the codes, they have the same comments, suggesting that they do the same thing:

/// <summary> /// Configures the port and base path the server should listen on when  /// running behind AspNetCoreModule. The app will also be configured  /// to capture startup errors. /// </summary> 

UseIIS is in Microsoft.AspNetCore.Server.IIS package, while UseIISIntegration is in Microsoft.AspNetCore.Server.IISIntegration.

What is the difference between the two? When do you need to use one versus the other? (or maybe both?)

UPDATE: There is a similar question on github, But there is no helpful answer there: https://github.com/aspnet/AspNetCore/issues/6197

like image 502
desmati Avatar asked Apr 14 '19 08:04

desmati


People also ask

What is the difference between UseIIS and UseIISIntegration?

UseIIS is in Microsoft. AspNetCore. Server. IIS package, while UseIISIntegration is in Microsoft.

What is the purpose of UseIISIntegration?

UseIISIntegration() − This tells ASP.NET that IIS will be working as a reverse proxy in front of Kestrel. This then specifies some settings around which port Kestrel should listen on, forwarding headers, and other details.

What is Kestrel in .NET core?

Kestrel is a cross-platform web server for ASP.NET Core. Kestrel is the web server that's included and enabled by default in ASP.NET Core project templates. Kestrel supports the following scenarios: HTTPS. HTTP/2 (except on macOS†)

How do I know if net core hosting bundle is installed?

To determine the version of the installed ASP.NET Core Module: On the hosting system, navigate to %PROGRAMFILES%\IIS\Asp.Net Core Module\V2 .


1 Answers

Until ASP.NET Core 2.2, ASP.NET Core was hosted out-of-process in IIS, meaning we had two processes for an application:

  1. w3wp.exe, the IIS process; and
  2. dotnet.exe, the ASP.NET Core process, where the Kestrel web server was started.

This means that IIS and Kestrel were communicating between those two processes.

For this scenario, you would use UseIISIntegration.


ASP.NET Core 2.2 introduced in-process hosting, where your ASP.NET Core app is ran inside of the IIS w3wp.exe process, removing the need for the Kestrel web server, in which case you want to use UseIIS.

Notes:

  • the official documentation seems to indicate that the CreateDefaultBuilder method will call the appropriate method by itself; see https://docs.microsoft.com/en-us/aspnet/core/host-and-deploy/iis/?view=aspnetcore-2.2#enable-the-iisintegration-components
  • Rick Strahl has some nice diagrams to show the differences between out-of-process and in-process hosting in the following blog post: https://weblog.west-wind.com/posts/2019/Mar/16/ASPNET-Core-Hosting-on-IIS-with-ASPNET-Core-22
like image 145
Mickaël Derriey Avatar answered Oct 21 '22 21:10

Mickaël Derriey