ASP.NET Core hosting models: Kestrel as an edge server, Kestrel behind a reverse proxy, IIS in-process and out-of-process via the ASP.NET Core Module (ANCM), and HTTP.sys, with when to choose each.
Kestrel is the default, cross-platform server built into ASP.NET Core and is fine to run directly, which is what you do in containers and on Linux. On Windows with IIS, the ASP.NET Core Module (ANCM) connects IIS to your app in one of two ways: in-process (the default), where the app runs inside the IIS worker process w3wp.exe using IISHttpServer instead of Kestrel and is fastest on IIS; or out-of-process, where IIS reverse-proxies to Kestrel running in a separate dotnet process. HTTP.sys is a Windows-only, kernel-mode server for when you need Windows authentication, port sharing or kernel caching without IIS. The trade-off: Kestrel is portable and simple, IIS gives Windows process management, and HTTP.sys gives Windows features without IIS.
"There are really three servers. Kestrel is the default: cross-platform, fast, and since ASP.NET Core 2.x it's supported as an edge server facing the internet. In containers on AKS or Azure Container Apps I run Kestrel and let the platform's load balancer or ingress sit in front.
On Windows with IIS, the ASP.NET Core Module in
web.configdecides how IIS talks to the app. In-process, the default since .NET Core 3.0, loads the .NET runtime intow3wp.exeand usesIISHttpServer, so there's no Kestrel and no loopback hop, which is noticeably faster. Out-of-process starts Kestrel in a separatedotnetprocess and IIS forwards each request over localhost; I'd choose it only for edge cases like needing Kestrel-specific features or isolating a crash-prone app. The third option is HTTP.sys, a Windows kernel driver: it gives Windows Authentication with Kerberos, port sharing with other apps and kernel-mode caching without needing IIS, which suits intranet apps run as Windows services.The mistake I see is forgetting what changes behind a proxy: if IIS out-of-process, Nginx or a load balancer terminates TLS, the app sees HTTP and the proxy's IP unless you configure forwarded headers. Pick the server for the platform you deploy to, and treat the proxy as part of the app's configuration."
| Kestrel (edge or behind LB) | IIS in-process | IIS out-of-process | HTTP.sys | |
|---|---|---|---|---|
| OS | Windows, Linux, macOS | Windows | Windows | Windows |
| Server in the app | Kestrel | IISHttpServer |
Kestrel | HttpSysServer |
| Process | dotnet / your exe |
w3wp.exe |
w3wp.exe + dotnet |
your exe / Windows service |
| Windows auth | Negotiate package (Kerberos/NTLM) | Yes (IIS) | Yes (IIS forwards token) | Yes, native |
| Port sharing | No | Yes (IIS bindings) | Yes | Yes (URL ACLs) |
| Typical use | Containers, App Service on Linux, AKS | Existing IIS estates | Rare edge cases | Intranet services without IIS |
Moving an internal API from out-of-process to in-process IIS hosting typically removes a loopback hop and the double request parsing; teams report noticeably higher throughput for the same hardware (Microsoft's guidance quotes significantly better performance for in-process). When the same API later moved to AKS, IIS disappeared entirely and Kestrel ran behind the ingress controller, with UseForwardedHeaders restoring the real client IP for audit logs.
Checks that the candidate knows where their app actually runs and the performance and security consequences of that choice.
Green flags
w3wp.exe.Red flags
web.config does in ASP.NET Core.IServer abstractionASP.NET Core does not care which server it runs on. The host resolves one IServer from DI and calls StartAsync with the application's RequestDelegate. Kestrel (KestrelServer), IIS in-process (IISHttpServer) and HTTP.sys (HttpSysServer) are three implementations. WebApplication.CreateBuilder registers Kestrel and the IIS integration; when the app is launched by ANCM in-process, the IIS server is used.
ANCM is a native IIS module installed by the .NET Hosting Bundle. web.config tells it what to do:
<aspNetCore processPath="dotnet" arguments=".\MyApi.dll" hostingModel="inprocess" />
aspnetcorev2_inprocess.dll, starts the CLR inside w3wp.exe and calls your Main. Requests go from the HTTP.sys kernel queue to IIS to your pipeline in the same process.dotnet MyApi.dll with a random port in ASPNETCORE_PORT, then proxies each request over HTTP to localhost. It also restarts the process if it crashes.In-process: Client ββΊ HTTP.sys ββΊ IIS (w3wp.exe: ANCM ββΊ your pipeline)
Out-of-process: Client ββΊ HTTP.sys ββΊ IIS (w3wp.exe: ANCM) ββlocalhost HTTPβββΊ dotnet (Kestrel ββΊ pipeline)
Kestrel edge: Client ββΊ [cloud LB / ingress] ββΊ Kestrel ββΊ pipeline
Out-of-process parses each request twice (IIS, then Kestrel), copies the body across a loopback socket and doubles the connection count. In-process avoids all of that. The constraints: one app per app pool, and the app shares w3wp.exe's lifetime (an app pool recycle restarts your app).
HTTP.sys is the same kernel driver IIS uses. Hosting on it directly (builder.WebHost.UseHttpSys()) gives kernel-mode request queuing, kernel response caching, Windows authentication without extra packages, and URL-prefix based port sharing (registered with netsh http add urlacl). It cannot run on Linux and does not work with ANCM.
Any time something terminates the connection before your app (IIS out-of-process, Nginx, YARP, Azure Front Door, an ingress controller), Request.Scheme, Request.Host and Connection.RemoteIpAddress describe the proxy hop. UseForwardedHeaders reads X-Forwarded-For, X-Forwarded-Proto and X-Forwarded-Host, but only trusts them from configured KnownProxies/KnownNetworks (in .NET 10, also KnownIPNetworks). IIS integration configures this for you automatically.
hostingModel between inprocess and outofprocess and compare Task Manager processes.bombardier -c 100 -d 30s and compare requests per second.UseHttpSys() and enable Windows Authentication; log User.Identity.Name.RemoteIpAddress with and without UseForwardedHeaders.Choosing the server in Program.cs. Kestrel is the default; HTTP.sys is opt-in and Windows-only.
// Program.cs
using Microsoft.AspNetCore.HttpOverrides;
using Microsoft.AspNetCore.Server.HttpSys;
var builder = WebApplication.CreateBuilder(args);
if (OperatingSystem.IsWindows() && builder.Configuration.GetValue<bool>("Hosting:UseHttpSys"))
{
// Kernel-mode server: Windows auth and port sharing without IIS
builder.WebHost.UseHttpSys(options =>
{
options.Authentication.Schemes = AuthenticationSchemes.Negotiate;
options.Authentication.AllowAnonymous = false;
options.UrlPrefixes.Add("https://+:443/payroll/");
});
}
else
{
// Kestrel (also used when IIS hosts out-of-process)
builder.WebHost.ConfigureKestrel(k => k.AddServerHeader = false);
}
// Behind a proxy or load balancer: trust forwarded headers from known networks only
builder.Services.Configure<ForwardedHeadersOptions>(o =>
{
o.ForwardedHeaders = ForwardedHeaders.XForwardedFor | ForwardedHeaders.XForwardedProto;
o.KnownIPNetworks.Add(System.Net.IPNetwork.Parse("10.0.0.0/8"));
});
var app = builder.Build();
app.UseForwardedHeaders(); // first, so later middleware sees the real scheme and client IP
app.MapGet("/whoami", (HttpContext ctx) => new { ctx.Request.Scheme, Ip = ctx.Connection.RemoteIpAddress?.ToString() });
app.Run();
<!-- web.config for IIS: in-process is the default and the faster model -->
<configuration>
<system.webServer>
<handlers><add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModuleV2" resourceType="Unspecified" /></handlers>
<aspNetCore processPath="dotnet" arguments=".\Payroll.Api.dll" hostingModel="inprocess" stdoutLogEnabled="false" />
</system.webServer>
</configuration>
Kestrel:Endpoints and KestrelServerLimits. Instead: Add a proxy only for TLS offload, WAF, port sharing or central routing.w3wp.exe.http:// redirect URLs, causing redirect loops. Instead: Configure UseForwardedHeaders with known proxies or networks, early in the pipeline.X-Forwarded-For from anyone. Why it is wrong: Clients can spoof it to bypass IP-based rules or poison audit logs. Instead: Restrict trust to known proxies or networks.The choice is mostly decided by the platform, not by preference. On Linux containers there is nothing to choose: Kestrel, with the platform's ingress in front. On Windows, the decision is about who owns operations: if an infrastructure team runs IIS with certificate rotation, logging and app pool policies, in-process hosting fits that model. HTTP.sys is a niche tool for Windows services that need Kerberos or URL sharing.
| Option | When it fits | Cost | When not to |
|---|---|---|---|
| Kestrel edge in container | Greenfield, AKS, Container Apps | You or the platform handle TLS | Must share :443 on a Windows host |
| IIS in-process | Managed Windows/IIS estate | Windows licensing, app pool recycles restart the app | Linux or containers |
| IIS out-of-process | Need Kestrel features under IIS | Extra hop and process | Default choice |
| HTTP.sys | Intranet Windows service with Kerberos | Windows-only, URL ACL setup | Internet-facing cloud services |
CONNECT. HttpClient picks it up from system settings or HTTP_PROXY/HTTPS_PROXY/NO_PROXY.Behind a reverse proxy, the app sees the proxy's IP and often plain http. The proxy passes the originals in X-Forwarded-For and X-Forwarded-Proto, but ASP.NET Core only applies them via the ForwardedHeaders middleware, and by default only trusts proxies on loopback. So UseHttpsRedirection sees http, redirects to https, the proxy forwards as http again: a loop.
Fix: UseForwardedHeaders first, configured with the proxy's IPs or network in KnownProxies/known networks. Do not trust all sources, or clients can spoof their IP and scheme.
Properties/launchSettings.json defines launch profiles for local development: how to start the app, which URLs, and which environment variables. Visual Studio, Rider, VS Code with C# Dev Kit and dotnet run all read it, but it is not published. In this file I would flag: secrets are committed (a production connection string and API key), so they must be rotated now and moved to user secrets; the environment is Production, which switches on production behaviour and turns off user secrets, and combined with the production connection string means a developer's F5 talks to the live database; and it binds to 0.0.0.0 over plain HTTP, exposing the app to the network. I would replace it with HTTPS and HTTP profiles on localhost using Development, and add a separate production-like profile only if someone needs to test production behaviour against non-production resources.
Last updated 23 Nov 2026.