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.
On this page · 5 min · Intermediate
On this page
- In simple words
- Learning objectives
- Explanation
- Code example
- Step by step
- Real-world use
- Common mistakes
- Best practices
- Remember this
- Practice exercise
- Mini quiz
- Related topics
- My notes
- Reading time
- 5 min
- Difficulty
- Intermediate
- Updated
- Oct 30, 2026
Related tutorials
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#
# 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
StatusCode Content
---------- -------
200 HealthyThis example is illustrative. Copy or download it and run it in your own environment; the expected output is shown above.
Step-by-step explanation#
- publish produces the app files and web.config.
- The pool uses No Managed Code.
- The pool identity gets read access.
- 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#
A .NET 9 app needs the .NET 9 Hosting Bundle; otherwise you get HTTP 500.31 or 500.30.
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
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#
What does the .NET Hosting Bundle install?
Want more? Practise all IIS MCQs · IIS interview questions
My notes#
Saved in this browser.