# How to deploy ASP.NET Core to IIS: Hosting Bundle, web.config and 500.30 fixes

> Step by step, deploy an ASP.NET Core app to IIS on Windows Server: install the Hosting Bundle, pick in-process or out-of-process hosting, set up a No Managed Code pool and web.config, and fix 500.30, 500.31 and 502.5.

Source: https://zopanel.net/windows/blog/deploy-aspnet-core-to-iis  
Updated: 2026-11-27

## Key takeaways

- IIS needs the ASP.NET Core Hosting Bundle for the same major .NET version as your app; install it after IIS, then restart IIS.
- Use an application pool with No Managed Code; the ASP.NET Core Module, not the CLR in w3wp, runs your app.
- In-process is faster but allows one app per pool; out-of-process runs Kestrel behind IIS.
- 500.30 means the app crashed while starting, 500.31 means the right .NET runtime was not found; the stdout log and the Event Log tell you why.

To deploy ASP.NET Core to IIS, install the ASP.NET Core Hosting Bundle on the server, publish the app with `dotnet publish`, and point an IIS site at the published folder using an application pool set to **No Managed Code**. The `web.config` that `dotnet publish` writes tells the ASP.NET Core Module (ANCM) how to start your app. Most failures after that are a 500.30 (the app crashed on start) or a 500.31 (the runtime was not found), and both leave a clear trace in the logs.

This guide is narrower than our overview of [hosting ASP.NET and PHP side by side](/windows/blog/host-aspnet-php-on-iis): it covers one ASP.NET Core app on IIS 10, on Windows Server 2019, 2022 or 2025.

## Before you start: pick the .NET version

The Hosting Bundle you install must match the major version your app targets (`net8.0`, `net9.0`, `net10.0`). Microsoft's support for .NET 8 and .NET 9 ended on 10 November 2026; .NET 10 is the current long-term support release. The steps below are the same for each version, but new apps should target .NET 10, and existing .NET 8 or 9 apps should be planned for an upgrade.

Check what is already on the server:

```powershell
dotnet --list-runtimes
Get-ItemProperty 'HKLM:\SOFTWARE\Microsoft\IIS Extensions\IIS AspNetCore Module V2' -ErrorAction SilentlyContinue
```

## Step 1: install IIS, then the Hosting Bundle

Order matters. The Hosting Bundle registers the ASP.NET Core Module with IIS, so IIS must exist first.

```powershell
Install-WindowsFeature Web-Server, Web-Mgmt-Console
```

Download the Hosting Bundle for your .NET version from Microsoft's .NET download page (it is listed under "ASP.NET Core Runtime", Windows, "Hosting Bundle"), then install it silently and restart IIS:

```powershell
.\dotnet-hosting-<version>-win.exe /install /quiet /norestart
net stop was /y
net start w3svc
```

If you installed the bundle before IIS, run the installer again and choose **Repair**. Without the module, every request fails with **HTTP Error 500.19** and error code `0x8007000d`, because IIS cannot parse the `aspNetCore` section of `web.config`.

## Step 2: publish the app

On your build machine:

```powershell
dotnet publish .\MyApp.csproj -c Release -o .\publish
```

Copy the `publish` folder to the server, for example `C:\sites\myapp`. The folder contains `MyApp.dll`, its dependencies and a generated `web.config`.

A **framework-dependent** publish (the default) needs the .NET runtime on the server, which the Hosting Bundle provides. A **self-contained** publish (`-r win-x64 --self-contained`) carries its own runtime and produces `MyApp.exe`; the server then only needs the module.

## Step 3: create the pool and the site

The application pool must not load the .NET Framework CLR. In IIS that setting is called **No Managed Code**, which is an empty `managedRuntimeVersion`.

```powershell
Import-Module WebAdministration

New-WebAppPool -Name 'myapp'
Set-ItemProperty IIS:\AppPools\myapp -Name managedRuntimeVersion -Value ''
Set-ItemProperty IIS:\AppPools\myapp -Name processModel.loadUserProfile -Value $true

New-Website -Name 'myapp' -PhysicalPath 'C:\sites\myapp' `
  -HostHeader 'app.example.com' -Port 80 -ApplicationPool 'myapp'

icacls 'C:\sites\myapp' /grant 'IIS AppPool\myapp:(OI)(CI)RX'
```

Loading the user profile matters for ASP.NET Core Data Protection: without a profile, the keys that protect cookies and antiforgery tokens may not persist, and users are signed out after every pool recycle. For more on the pool account, see [IIS application pool identity explained](/windows/blog/iis-application-pool-identity).

## Step 4: understand web.config

The generated file looks like this:

```xml
<?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="dotnet"
                  arguments=".\MyApp.dll"
                  stdoutLogEnabled="false"
                  stdoutLogFile=".\logs\stdout"
                  hostingModel="inprocess">
        <environmentVariables>
          <environmentVariable name="ASPNETCORE_ENVIRONMENT" value="Production" />
        </environmentVariables>
      </aspNetCore>
    </system.webServer>
  </location>
</configuration>
```

For a self-contained app, `processPath` is `.\MyApp.exe` and `arguments` is empty. Keep secrets out of this file if you can; use environment variables set on the server or a secret store.

## In-process or out-of-process?

The `hostingModel` attribute decides where your code runs.

**In-process** (`inprocess`, the default for new projects): ANCM loads the .NET runtime and your app inside the IIS worker process, `w3wp.exe`. There is no extra hop, so it is the faster option. The limits: only one in-process app per application pool (a second one gives **500.35**), and the pool's bitness must match the app's (a mismatch gives **500.32**).

**Out-of-process** (`outofprocess`): ANCM starts your app as a separate process running Kestrel on a local port and forwards requests to it. Your app reads the port from the `ASPNETCORE_PORT` variable, which `UseIIS`/`UseIISIntegration` in the default host builder handles for you. If the process fails to start, you get **502.5 Process Failure**.

Pick in-process unless you have a reason not to, such as wanting the app's process separate from IIS, or running several apps in one pool.

## Troubleshooting 500.30, 500.31 and friends

Start with the error page and the substatus code. Then turn on the stdout log: set `stdoutLogEnabled="true"`, create the `logs` folder, and give the pool write access to it:

```powershell
New-Item -ItemType Directory C:\sites\myapp\logs
icacls 'C:\sites\myapp\logs' /grant 'IIS AppPool\myapp:(OI)(CI)M'
```

Reload the page and read the newest `stdout_*.log`. Turn the log off again when you are done: it is not rotated and grows without limit.

The module also writes to the Windows Application log:

```powershell
Get-WinEvent -LogName Application -MaxEvents 30 |
  Where-Object ProviderName -like 'IIS AspNetCore Module*' |
  Format-List TimeCreated, Message
```

The codes you will meet most often:

| Code | Meaning | Usual fix |
|---|---|---|
| 500.19 (`0x8007000d`) | IIS cannot read `web.config`; the module is missing | Install or repair the Hosting Bundle |
| 500.30 | In-process app failed to start | Read stdout/Event Log: often a bad connection string, missing config file or a permission error |
| 500.31 | ANCM could not find the native dependencies (the runtime) | Install the Hosting Bundle for the app's major version, or publish self-contained |
| 500.32 | Bitness mismatch | Turn off **Enable 32-Bit Applications** for a 64-bit app |
| 500.35 | Two in-process apps in one pool | Give each app its own pool |
| 500.37 | App did not start within the time limit | Raise `startupTimeLimit` or fix slow startup work |
| 502.5 | Out-of-process app failed to start | Same checks as 500.30 |

A quick test that bypasses IIS: open a console as an administrator, go to the app folder and run `dotnet .\MyApp.dll`. If it crashes there, the problem is the app or its configuration, not IIS. Remember that it runs as you, not as the pool, so a permission problem may not show up.

For general IIS 500 errors, see [IIS 500 internal server error troubleshooting](/windows/blog/iis-500-internal-server-error).

## FAQ

### Do I need the full .NET SDK on the server?

No. The server needs only the Hosting Bundle (runtime plus module). Build and publish on a build machine or in CI.

### Can I run two ASP.NET Core apps in one application pool?

Only if they use out-of-process hosting. Two in-process apps in one pool fail with 500.35. One pool per app is the cleaner choice anyway.

### Why do my users get logged out after the pool recycles?

The Data Protection keys were not persisted. Turn on **Load User Profile** for the pool, or configure Data Protection to store keys in a folder the pool can write.

### Do I have to restart IIS after installing a new Hosting Bundle?

Yes. Run `net stop was /y` and `net start w3svc`, or reboot.

## In Zopanel for Windows

Zopanel runs ASP.NET Core 10 apps a slightly different way: each app is its own Windows service running Kestrel behind IIS and ARR, both framework-dependent and self-contained builds, inside a Job Object with the plan's CPU and memory limits. Deploys are releases from a zip or Git with a health check and rollback, and environment variables and secrets are set per site. This is available on Server 2019, 2022 and 2025. In-process hosting through the Hosting Bundle is in the catalog but **experimental**: we have not run an app that way on Windows yet. The runtime in the catalog is .NET 10. Details are in [ASP.NET on Zopanel](/windows/docs/aspnet) and on the [apps feature page](/windows/features/apps). The Free plan covers 1 server and 10 sites: [download it](/windows/download) or see [pricing](/windows/pricing).
