Pro Code Guide

Developer’s Guide To Programming

HOME    CONTACT   ABOUT

ASP.NET Core Hosting on IIS on Windows

Updated Feb 2, 2021 | 0 comments

This article will provide details about how to perform ASP.NET Core hosting on IIS for both web application and Web API. .NET Core 2.2 onwards there were significant changes in the hosting model to IIS. Prior to .NET Core 2.2 only option available was to use IIS as a reverse proxy to the ASP.NET Core Kestrel web server.

With .NET Core 2.2 option was added for direct in-process hosting to IIS which can improve the performance significantly. The old approach with IIS as a reverse proxy is also available as an out-of-process hosting model. ASP.NET Core hosting on IIS supports two models for hosting on the IIS i.e. In-process hosting model & out-of-process hosting model.

ASP.NET Core Hosting on IIS is different as compared to ASP.NET Webforms or ASP.NET MVC.

Supported operating systems

  • Windows 7 or later
  • Windows server 2012 R2 or later

Apps published for 32 bit (x86) and 64 bit (x64) are supported. Application pools under should be configured accordingly for 32-bit & 64-bit apps.

Type of Hosting Models

ASP.NET Core Hosting on IIS
In-process hosting model

As the name suggests ASP.NET Core application runs in the same process as IIS (w3wp.exe) and it does not use the Kestrel web server. This hosting model uses IISHttpServer that is hosted directly inside the application pool. This hosting model provides a significant performance improvement over the other out-of-process model as it does not have to forward requests to Kestrel for processing. IIS handles process management in the traditional way with the help of windows process activation service (WAS).

Request flow details:

  • Request arrives from web at HTTP.sys
  • HTTP.sys routes the request to IIS
  • ASP.NET Core module receives the request and passes it to IIS HTTP Server.
  • IISHTTPServer passes the request to ASP.NET Core middleware pipeline.
  • ASP.NET Core application handles the request and returns response
ASP.NET Core 5 Design Patterns: Thinking code using architectural principles, testing, design patterns, and C
Out-of-process hosting model

Again as the name suggests here ASP.NET Core application runs in a separate process from the IIS worker process. This is similar to what was available in ASP.NET Core versions prior to 2.2. ASP.NET Core module handles process management, this module is responsible for starting the ASP.NET Core App when the first request arrives & also restarts if it shuts down or crashes.

Here IIS acts as a reverse proxy to Kestrel web server where ASP.NET Core application is running. For application to be configured as an out-of-process model it needs to specify UseIISIntegration as part of WebHostBuilder code in the program.cs file. ASP.NET Core module doesn’t support HTTPS forwarding.

Steps for ASP.NET Core hosting on IIS

  • Publish your application
  • Install/Enable IIS Server on windows
  • Install the .NET Core Hosting Bundle
  • Create a new application pool & website for your application
Publish your Application

Right click on project in Solution Explorer and select Publish option. This should being up the screen to publish your code. Select Folder option to publish all the files to a folder. This folder will be configured in IIS as website folder.

IIS Configuration

Use the Add Roles & Features wizard to Enable IIS on Windows server operating system.

IIS Installation

Select following services under web server on Select role services screen

IIS Installation Select Services

For windows desktop operating system select Control Panel ==> Program ==> Program & Features ==> Turn windows features on or off and select following features for installations

IIS Installation on Windows Desktop

Newsletter Subscription

Stay updated! Instantly get notified about my new articles in your mailbox by subscribing via email

Install .NET Hosting Bundle

You can download the required version of the hosting bundle from here. The hosting bundle installs the .NET Core Runtime, .NET Core Library, and the ASP.NET Core Module.

If the Hosting Bundle is installed before IIS, the bundle installation must be repaired. Run the Hosting Bundle installer again after installing IIS.

Create IIS Site

Open IIS Manager & expand server node in connections panel on left hand side. Right click site folder and select “Add Website…” from the context menu. Provide Site name, Physical path (where code was published), binding configuration details & click on ok.

IIS Create Website

Finally browse and check your website.

Summary

ASP.NET Core hosting on IIS supports two models for hosting on the IIS i.e. In-process hosting model & out-of-process hosting model. .NET Core 2.2 onward there were significant changes in the hosting model to IIS.

In-process hosting model provides a significant performance improvement over the other out-of-process model as it does not have to forward requests to Kestrel for processing

References: https://docs.microsoft.com/en-us/aspnet/core/host-and-deploy/iis/?view=aspnetcore-3.1

You can also check my other Article on Configuring multiple ASP.NET Core hosting environment: https://procodeguide.com/programming/asp-net-core-hosting-environment/

Hope you found this article useful. Your support is appreciated!
Buy me a coffeeBuy me a coffee
Home 9 Programming 9 ASP.NET Core Hosting on IIS on Windows

Set start URL in ASP.NET Core – Quick & Easy ways

This article will cover the ways to set start URL in ASP.NET Core 5 applications i.e. change the default URL (http://localhost:5000) in ASP.NET Core applications. When you create any new ASP.NET Core application whether its MVC App or Web API and run it then it will...

Hangfire in ASP.NET Core – Easy way to Schedule Background Jobs

This article covers detail about how to integrate Hangfire in ASP.NET Core applications which is an easy way to schedule background jobs in .NET Core and .NET based applications. Background jobs or tasks allow the programmers to execute code on a different thread but...

How to Send Emails in ASP.NET Core – Quick & Easy Guide

These days sending emails like user email id confirmation, OTP emails, acknowledgments, etc. is a very common requirement of any application. In this article, we will see a demo about how to send emails in ASP.NET Core in quick & easy steps. We will create an...

ML.NET – Machine Learning with .NET Core – Beginner’s Guide

This article will get you started with the fundamentals of Machine Learning and how to get started with Machine Learning with .NET Core i.e. ML.NET. We will even learn different concepts of Machine learning with a brief overview. Introduction to Machine Learning...

Implement Cookie Authentication in ASP.NET Core – Detailed Guide

This article will get you started with implementing cookie authentication in ASP.NET Core applications. Cookie authentication allows you to have your own login/register screens & custom logic for user-id/password validation without the need to use ASP.NET Core...

ASP.NET Core Identity Roles based Authorization

This article will get you started with what are ASP.NET Core Identity roles and the need for roles, how to enable ASP.NET Core Identity roles in MVC Application, and how to implement role-based authorization. Role-based authorization is for basic authorization where...

Dependency Injection in ASP.NET Core 3.1 – Beginner’s Guide

This article will cover in details dependency injection in ASP.NET Core 3.1. ASP.NET Core is designed from the ground up to support the dependency injection design pattern. Dependency injection in ASP.NET Core provides a technique to create applications that are...

Real-time Web Applications with SignalR in ASP.NET Core 3.1

In this article, we will learn about real-time web & how to build real-time web applications using SignalR in ASP.NET Core. As part of this article, we will work on an application that can send real-time messages/alerts to all connected users or private messages...

Code Profiling using MiniProfiler in ASP.NET Core 3.1

This article will get you started with how to enable miniprofiler in ASP.NET Core to measure the performance of your application. MiniProlifer helps you understand how your application is performing by allowing you to profile any part of code in ASP.NET Core...

Microservices with ASP.NET Core 3.1

Microservices is a type of Architecture in which application is created as multiple small independent serviceable components. This article will cover in detail how to create microservices with ASP.NET Core, Serilog, Swagger UI, Health Checks & Docker containers....

0 Comments

Submit a Comment

Your email address will not be published. Required fields are marked *