# ASP.NET Core on IIS: Hosting Bundle, ANCM and 500.30

> Install the ASP.NET Core Hosting Bundle, publish an app, set the app pool to No Managed Code, and diagnose 500.30/502.5 without guessing.

**Tested on**

- Build: 26100.33650
- Edition: Standard / Datacenter
- Architecture: x64
- Evidence: E1
- Verified: 2026-10-29

## The short answer

1. Install the **ASP.NET Core Hosting Bundle** (includes the runtime + ANCM).
2. Publish the app (`dotnet publish -c Release`).
3. Point an IIS site at the publish folder.
4. Set the app pool to **No Managed Code**.
5. Fix 500.30 by reading the app’s stdout log, not by reinstalling IIS.

## Install

Download the Hosting Bundle matching the app’s major version, run it, then:

```powershell
dotnet --list-runtimes
Get-WebGlobalModule -Name AspNetCoreModuleV2
```

`AspNetCoreModuleV2` must be present. If not, repair the Hosting Bundle and restart IIS.

## Publish

```powershell
dotnet publish C:\src\app\App.csproj -c Release -o C:\sites\app
```

Publish output includes `web.config` with the ANCM handler. Do not hand-write it unless you know the schema.

## IIS site

- Physical path: `C:\sites\app`
- App pool: new pool, **No Managed Code**
- Binding: HTTPS with the right certificate
- Identity: app pool identity needs read/execute on the publish folder

## In-process vs out-of-process

```xml
<aspNetCore processPath="dotnet" arguments=".\App.dll"
            hostingModel="inprocess" />
```

- **in-process**: app runs inside `w3wp.exe`; faster, default for modern templates.
- **out-of-process**: ANCM launches `dotnet App.dll`; easier to see a separate process, slightly more overhead.

Pick one; do not mix `hostingModel` values across environments without testing.

## 500.30 / 502.5

`500.30` means the app failed to start. Enable stdout logs in `web.config`:

```xml
<aspNetCore processPath="dotnet" arguments=".\App.dll"
            stdoutLogEnabled="true"
            stdoutLogFile=".\logs\stdout" />
```

Then read `logs\stdout_*.log`. Common causes:

- missing runtime version;
- wrong `arguments` path;
- app throws at startup (config/DB/cert);
- app pool identity cannot read the folder or write logs;
- port/URL binding conflict.

`502.5` is the same family: ANCM could not start the process.

> **Caution: Do not set the app pool to v4.0**
>
> ASP.NET Core does not run as .NET Framework. The pool must be **No Managed Code**; the app’s runtime comes from the Hosting Bundle/ANCM.

## Verify

```powershell
Invoke-WebRequest https://app.example/ -UseBasicParsing | Select-Object StatusCode
Get-Content C:\sites\app\logs\stdout_*.log -Tail 50
Get-IISAppPool | Where-Object Name -eq 'apppool'
```

Check the response, the stdout log and the pool identity. Do not debug by recycling blindly.

## Lab boundary

E1. The lab did not install the Hosting Bundle or deploy an ASP.NET Core app; the steps are the production checklist for Server 2025.

## Sources

- [Microsoft Learn — Host ASP.NET Core on Windows with IIS](https://learn.microsoft.com/en-us/aspnet/core/host-and-deploy/iis/)
- [Microsoft Learn — ASP.NET Core Module](https://learn.microsoft.com/en-us/aspnet/core/host-and-deploy/aspnet-core-module)
- [Microsoft Learn — Hosting Bundle](https://learn.microsoft.com/en-us/aspnet/core/host-and-deploy/iis/hosting-bundle)

---

Source: https://winbook.fyi/en/server/runtimes/aspnet-core/
