IIS (Internet Information Services) · Hosting Applications

Hosting ASP.NET Core

This is the most common IIS task for .NET developers: take an ASP.NET Core app from Visual Studio to a running IIS site.

Intermediate 5 min Lesson 11 of 33Covers IIS 10 on Windows Server 2019/2022/2025 and Windows 10/11.
Before you start:Application Pools
0/33 in IIS
On this page · 5 min · Intermediate

In simple words#

IIS is the shop building and your ASP.NET Core app is the shopkeeper. The ASP.NET Core Module (installed by the Hosting Bundle) is the front door that lets customers in to the shopkeeper. In-process: the shopkeeper sits inside the building; out-of-process: in a cabin next door.

Hosting Bundle
Installs the .NET runtime + ASP.NET Core Module.
In-process
App runs inside w3wp.exe (fastest, default).
Out-of-process
IIS proxies to a separate Kestrel process.

Learning objectives#

  • Install the .NET Hosting Bundle
  • Publish an ASP.NET Core app
  • Create the site and app pool
  • Choose in-process or out-of-process hosting

Explanation#

Install the .NET Hosting Bundle matching your app’s major version (it includes the runtime and the ASP.NET Core Module V2). Restart IIS afterwards (net stop was /y && net start w3svc, or iisreset).

Publish: dotnet publish -c Release -o C:\inetpub\shop. The publish includes a generated web.config.

Create a site pointing to that folder with an app pool set to No Managed Code.

Hosting model: in-process (default) runs the app inside w3wp.exe for best performance; out-of-process runs Kestrel separately with IIS as a reverse proxy.

Code example: From publish to running site#

PowerShellFrom publish to running site Illustrative
# 1. Publish (on the build machine or server)
dotnet publish .\Shop.Web\Shop.Web.csproj -c Release -o C:\inetpub\shop


# 2. App pool + site
Import-Module WebAdministration
New-WebAppPool -Name ShopPool
Set-ItemProperty IIS:\AppPools\ShopPool managedRuntimeVersion ""
New-Website -Name Shop -PhysicalPath C:\inetpub\shop -ApplicationPool ShopPool -HostHeader shop.example.com -Port 80


# 3. Permissions and environment
icacls C:\inetpub\shop /grant "IIS AppPool\ShopPool:(OI)(CI)RX"
Add-WebConfigurationProperty -PSPath "IIS:\Sites\Shop" -Filter "system.webServer/aspNetCore/environmentVariables" `
  -Name "." -Value @{ name = 'ASPNETCORE_ENVIRONMENT'; value = 'Production' }


# 4. Test
Invoke-WebRequest http://shop.example.com/health -UseBasicParsing | Select-Object StatusCode, Content
Expected output
StatusCode Content
---------- -------
       200 Healthy

This example is illustrative. Copy or download it and run it in your own environment; the expected output is shown above.

Step-by-step explanation#

  1. publish produces the app files and web.config.
  2. The pool uses No Managed Code.
  3. The pool identity gets read access.
  4. The environment variable is stored in web.config’s aspNetCore section.

Real-world use case#

An internal HR portal built with ASP.NET Core MVC runs on the company’s Windows Server with IIS and Windows authentication.

Common mistakes#

Hosting Bundle for the wrong .NET version

A .NET 9 app needs the .NET 9 Hosting Bundle; otherwise you get HTTP 500.31 or 500.30.

Locked files during redeploy

Drop an app_offline.htm into the folder (or stop the pool) before copying new files.

Best practices#

  • Matching Hosting Bundle
  • In-process hosting unless you need otherwise
  • Use app_offline.htm during deployments
  • Health check endpoint for monitoring

Remember this#

Hosting Bundle → publish → site + No Managed Code pool.

In-process = inside w3wp, fastest.

app_offline.htm unlocks files for deploys.

Practice exercise#

Your task: Take the site offline safely during a deployment.

Show solution
PowerShell Illustrative
Set-Content C:\inetpub\shop\app_offline.htm "<h1>Updating, back in a minute</h1>"
# copy new files…
Remove-Item C:\inetpub\shop\app_offline.htm

Mini quiz#

Hosting ASP.NET Core quizMultiple choice Question 1 of 1

What does the .NET Hosting Bundle install?

Score so far: 0/0

Want more? Practise all IIS MCQs · IIS interview questions

My notes#

Saved in this browser.

Progress is saved in this browser. Sign in to sync.