How to Deploy ASP.NET Core 10 Web API to IIS on Windows Server – Complete Guide (2026)
An API that runs from Visual Studio can still fail on a Windows server. The server needs the right runtime and IIS module, the site must point at published files, and the worker process needs access to the resources the application uses.
This guide explains how to deploy ASP.NET Core 10 Web API to IIS on Windows Server. We will publish a small API, configure a dedicated IIS site with HTTPS, verify a known endpoint in Postman, and diagnose the most common deployment errors.
How do you deploy an ASP.NET Core 10 API to IIS?
Enable the IIS server role, install the .NET 10 Hosting Bundle, publish the application in Release mode, and deploy the complete publish output to the site's physical folder. Use a dedicated application pool, grant the required folder access, configure a hostname and HTTPS certificate, then test a mapped API endpoint.
Example choices: a supported x64 Windows Server installation, framework-dependent win-x64 output, in-process hosting, and an HTTPS binding on port 443. api.example.com is a placeholder: replace it with a hostname you control. The public sample endpoint returns no credentials or infrastructure details.
How IIS and the ASP.NET Core Module work together
The ASP.NET Core Module (ANCM) is a native IIS module installed by the Hosting Bundle. In-process hosting runs the app inside the IIS worker process, w3wp.exe, using IIS's in-process server. Out-of-process hosting runs the application in a separate process on Kestrel, and ANCM forwards requests to it.
It is therefore inaccurate to say every ASP.NET Core app on IIS uses Kestrel as a reverse-proxy backend. This guide explicitly publishes for in-process hosting. Microsoft's ANCM documentation explains both models.
Prerequisites: development machine versus server
- Development/build machine: .NET 10 SDK, plus Visual Studio 2026 version 18.0 or later with the ASP.NET and web development workload if using the IDE.
- Server: a Windows Server version supported by .NET 10, such as Windows Server 2022 or 2025, IIS, and the .NET 10 Hosting Bundle.
- Network and identity: an approved hostname, DNS record, trusted TLS certificate with its private key, and administrative access for server configuration.
- Testing: Postman and access from both the server and an intended client network.
A framework-dependent app needs the matching shared frameworks on the server; a newer major runtime alone is not a substitute for .NET 10. The production server normally does not need the SDK or Visual Studio. Check supported operating systems and IDE compatibility against Microsoft's .NET installation guidance.
Step 1: Create a small Web API
In Visual Studio, create an ASP.NET Core Empty project named IisDeploymentApi, select .NET 10, and configure HTTPS. Alternatively, use the CLI:
Replace Program.cs with:
Replace appsettings.json with:
Change AllowedHosts to match your real hostname before publishing. Host filtering is separate from TLS certificate validation and IIS site bindings. Do not put passwords or connection strings containing credentials into this committed file.
This example uses a Minimal API to isolate deployment from database or authentication problems. The health route checks that a request reaches application code; it does not verify database connectivity or full application readiness.
Step 2: Test locally before publishing
Send GET https://localhost:7083/api/health in Postman and expect status 200 with the JSON shown later. The local HTTPS development certificate is for your machine; do not use it as the public production certificate. The application's HTTP-to-HTTPS redirect targets production port 443, so this local test intentionally calls HTTPS directly.
Step 3: Enable IIS on Windows Server
Open Server Manager → Add Roles and Features → Role-based or feature-based installation. Select the target server, enable Web Server (IIS), and include its management tools. Retain the HTTP logging, request-monitoring, and request-filtering role services needed by your server policy.
For the basic IIS role, an administrator can instead run:
Complete any restart requested by Windows. ASP.NET Core does not require enabling legacy ASP.NET 4.x just to host this app. Install optional features such as Windows Authentication only when the application needs them. Leave directory browsing disabled.
Step 4: Install the .NET 10 Hosting Bundle after IIS
Download the supported .NET 10 Windows Hosting Bundle from Microsoft's .NET 10 downloads and run it as administrator. Choose the Hosting Bundle, not only the desktop runtime. It installs the IIS integration needed by ANCM along with the runtime components.
If the bundle was installed before IIS, rerun the installer and repair it after IIS is present. Finish the restart requested by the installer or plan an IIS service restart. The following commands affect all IIS sites on the server, so use a maintenance window:
Check the server runtime installation:
For this deployment, verify 10.0.x entries for Microsoft.NETCore.App and Microsoft.AspNetCore.App. That command confirms runtime availability, not ANCM registration; verify the Hosting Bundle installation and IIS integration separately if hosting still fails. See Microsoft's Hosting Bundle instructions.
Step 5: Publish with the CLI or Visual Studio
CLI: produce a complete Release artifact
Run this on the build machine from the project directory:
The app remains framework-dependent, so the server supplies the .NET runtime. UseAppHost=false makes the published launch configuration use dotnet and the DLL. The command also fixes the intended hosting model and publishes ASPNETCORE_ENVIRONMENT as Production.
Visual Studio: publish to a folder
- Right-click the project → Publish → Folder.
- Choose a staging folder outside the project source tree.
- Set Release configuration, net10.0, framework-dependent deployment, and the win-x64 target runtime.
- Publish, then inspect the output and generated web.config. Configure the environment through your publish profile or IIS configuration.
The exact generated processPath can differ when an apphost executable is enabled. Keep the generated value matched to the files you publish; do not force the XML below onto a differently published app. Microsoft's publish-profile guidance covers the settings.
Step 6: Understand the generated web.config
The Web SDK generates or transforms web.config during publishing. For the CLI choices above, the relevant structure is represented by:
AspNetCoreModuleV2 is the IIS handler module; dotnet starts the framework-dependent DLL; hostingModel selects in-process hosting. The nonsecret environment value selects production behavior. stdoutLogEnabled stays false for normal operation.
Place this generated file at the published application's root, alongside the DLL, deps.json, and runtimeconfig.json files. It is not the same as appsettings.json. Never remove web.config to work around a startup problem or turn on directory browsing to make the folder visible. Read Microsoft's web.config guidance.
Step 7: Create a dedicated IIS application pool and site
- Create C:\Sites\IisDeploymentApi on the server.
- In IIS Manager → Application Pools → Add Application Pool, create IisDeploymentApiPool with No Managed Code and Integrated pipeline mode.
- Keep the pool's identity as ApplicationPoolIdentity. For this x64 deployment, set Enable 32-Bit Applications to False.
- Add a website named IisDeploymentApi, select that pool, and set the physical path to C:\Sites\IisDeploymentApi.
- Use an explicit hostname and a binding that does not conflict with another site.
No Managed Code refers to the desktop .NET Framework CLR setting; it does not mean ASP.NET Core cannot run managed code. The application loads CoreCLR through its IIS integration. Use a separate app pool per in-process application.
Step 8: Grant only the folder permissions the app needs
After the pool exists, grant its virtual account read and execute access to the application folder:
Do not grant Everyone Full Control or run the pool as an administrator to fix a permissions error. The deployment account and the runtime identity have different jobs. Grant write access only to dedicated folders where the app genuinely writes data or temporary diagnostics; keep those outside the web root where practical.
If you change the pool identity or anonymous-authentication identity, review the corresponding ACLs. Database authentication is another permission boundary: your administrator's SQL access does not automatically become the worker process's access.
Step 9: Configure HTTPS, DNS, and bindings
- Obtain a trusted certificate whose subject alternative name includes your API hostname. Install it with its private key in the server's appropriate computer certificate store.
- In IIS Manager → site → Bindings, add HTTPS on port 443 with the hostname and certificate. Enable SNI when sharing an IP and port across hostnames as appropriate.
- Point DNS at the correct server or approved load balancer. Allow required HTTPS traffic through Windows Firewall and network security controls.
- If you offer HTTP-to-HTTPS redirection, add a matching hostname binding on port 80. Otherwise, expose only HTTPS and document that clients must use it.
Use the real hostname in Postman so certificate and binding selection are tested. Do not disable client certificate verification as your deployment fix. Our MMC certificate-import guide explains certificate-store operations; importing a root or intermediate certificate alone does not create an IIS server certificate with its private key.
IIS normally terminates TLS in this setup. Additional proxies require a deliberate forwarded-header trust configuration; do not trust forwarded headers from arbitrary clients. Microsoft's IIS HTTPS guidance covers bindings and certificate setup.
Step 10: Choose file deployment or Web Deploy
File-based publishing
Copy the contents of the publish directory—not the source folder and not a parent folder containing publish—to the site's physical path. Preserve an approved rollback artifact and protect persistent uploads and host-specific configuration.
For an update to a running app, place app_offline.htm at the application's root, allow ANCM to shut the app down, deploy the complete artifact, then remove the offline file. It can contain:
Do not overwrite locked DLLs one at a time while requests are being served. An offline-file deployment has downtime; do not describe it as zero downtime. If the update fails, retain the maintenance state while restoring the known-good artifact and compatible configuration. Avoid mirroring or deletion commands that accidentally remove persistent data.
Web Deploy from Visual Studio
Web Deploy is a separate deployment tool; installing the Hosting Bundle does not configure it. Have the server administrator install and configure Web Deploy and the required management/delegation components. In Visual Studio, choose an IIS/Web Deploy publish target or import an approved profile, supply the configured server endpoint and IIS site name, validate the connection, review the changes, then publish.
A remote management endpoint often uses HTTPS port 8172, but use the endpoint actually configured by the administrator. Restrict deployment access, validate its certificate, and protect publish credentials and profiles. Do not open management access to the internet merely to make publishing convenient. Review Microsoft's Web Deploy overview.
Production environment variables and connection strings
Confirm Production in the application's effective configuration. launchSettings.json is development tooling configuration, not the IIS production settings source. The publish command writes ASPNETCORE_ENVIRONMENT; remove conflicting environment settings, including a different DOTNET_ENVIRONMENT value, rather than relying on accidental precedence.
For an app-specific setting, use the IIS app-pool environmentVariables collection through Configuration Editor or the administrator's deployment configuration. Keep the app isolated in its own pool, and restart the affected worker process after configuration changes. Microsoft documents this IIS environment-variable collection.
ASP.NET Core maps ConnectionStrings__MainDb to ConnectionStrings:MainDb, which application code can read with GetConnectionString("MainDb"). This demo does not use a database, so it needs no connection string. For a real API, use an approved secret manager or protected server configuration and a least-privilege database identity. Do not deploy development User Secrets or commit production credentials to appsettings files or publish profiles. Environment values are not an encrypted vault, and web.config should not become a secret dump.
Verify the deployed endpoint in Postman
Expect HTTP 200 and Content-Type application/json. Test from the server using the hostname, then from an intended client network. Confirm the certificate chain, hostname, status, and body. Keep certificate verification enabled.
The root URL / has no mapped endpoint in this example, so an application-generated 404 there is expected. Similarly, /swagger returns 404 because this sample does not install or map Swagger. Neither response by itself proves the API failed to start. Test /api/health.
Troubleshooting: 500.30, 500.31, 502.5, 403.14, and 404
| Error | When it applies | First checks |
|---|---|---|
| 500.30 | In-process application startup failure | Application Event Log, startup exception, configuration and resource permissions |
| 500.31 | ANCM cannot load required in-process runtime/native dependencies | Required shared framework, Hosting Bundle and native dependency availability |
| 502.5 | Out-of-process backend fails to launch or listen | Actual hostingModel, processPath, arguments, backend startup logs |
| 403.14 | IIS treats the request as a directory with no default document and browsing disabled | Physical path, complete publish output, web.config and handler setup |
| 404 | Resource or route not found; may originate in IIS or application routing | Hostname binding, requested path, IIS substatus, application/sub-application path and mapped endpoints |
Do not treat these as interchangeable runtime errors. For this in-process sample, 502.5 should prompt you to check whether the deployed configuration actually uses out-of-process hosting. A different architecture mismatch can have its own error, such as 500.32; inspect the recorded diagnostic instead of assuming every load failure is 500.31.
A 500.30 can be caused by an application exception even when the runtime is installed. A 403.14 is not a reason to enable directory listing. A 404 requires checking the requested route and IIS substatus before changing the Hosting Bundle. Microsoft's IIS troubleshooting reference explains these failure categories.
Use Event Viewer, stdout diagnostics, and application logs safely
- Record the failing URL, status/substatus, timestamp, and deployment version.
- In Event Viewer → Windows Logs → Application, inspect relevant IIS AspNetCore Module V2 and .NET Runtime entries around that time.
- Review IIS request logs for request status and substatus. These are different from your application's structured logs.
- If startup details are still missing, temporarily enable ANCM stdout logging to a restricted location.
For temporary diagnostics, create a separate directory and grant only the pool write access there:
In the existing aspNetCore element, temporarily change stdoutLogEnabled to true and stdoutLogFile to C:\ProgramData\IisDeploymentApi\Diagnostics\stdout. Reproduce the failure once, inspect the resulting file securely, then set stdoutLogEnabled back to false. Logs can contain sensitive configuration, so control access and retention.
ANCM stdout files are not a normal rotating application-log solution. Watch disk usage, clean up through your retention process, and configure an appropriate provider for routine structured logs. Keep Production enabled rather than exposing a developer exception page publicly. See Microsoft's ANCM logging guidance.
An administrator can also stop the affected site or pool and try starting the published DLL from a console to reveal startup errors:
Stop this diagnostic process after inspection. Your console account does not have the same identity, permissions, or automatically injected IIS environment as the worker, so a console success does not prove IIS access is correct. Do not dump all environment variables or secrets into a support log.
Practical deployment checklist
- Supported Windows Server, patched .NET 10 Hosting Bundle, and verified ANCM installation.
- Release publish artifact, correct architecture, and complete generated web.config.
- Dedicated app pool, No Managed Code, matching bitness, and least-privilege ACLs.
- Correct physical path, hostname bindings, DNS, firewall access, and trusted HTTPS certificate.
- Production settings, protected secrets, and no development exception pages.
- Successful /api/health test from both the server and a client network.
- Working rollback plan, routine logs, monitoring, and temporary stdout diagnostics disabled.
Frequently asked questions
Do I need the .NET 10 SDK on the IIS server?
Not for this framework-dependent deployment. Publish on a build machine and install the required runtime/Hosting Bundle on the server. The SDK is needed where you build or publish.
Does a self-contained deployment remove the need for ANCM?
No. A self-contained app carries its runtime, but IIS hosting still needs the ASP.NET Core Module. Its generated processPath and architecture can differ from this framework-dependent DLL example.
Why does No Managed Code work with C#?
That IIS setting concerns the desktop CLR. ANCM initializes the ASP.NET Core hosting path; it does not require choosing a .NET Framework CLR version in the pool.
Should I use iisreset after every deployment?
No. Prefer an update strategy scoped to the affected app. A server-wide restart interrupts unrelated sites. Our IIS command-line restart guide is useful when a planned wider restart is actually required.
Can I host the API under /myapi instead of its own site?
Yes, but configure an IIS application and a suitable dedicated pool rather than treating the folder as a virtual directory. Account for the application's path base when constructing request URLs and resource links.
Why is the local app working but the IIS app failing?
Compare runtime availability, published files, environment, worker identity, permissions, and bindings. IIS does not inherit your developer account's secrets, database privileges, or launch profile.
Conclusion and verification status
A reliable IIS deployment combines a correct publish artifact with the right runtime/module, a deliberately configured application pool, and secure server settings. Verify a known API route before diagnosing a missing homepage as a startup failure.
This guide was checked against official Microsoft documentation on November 3, 2026. The code and commands have not been executed on a Windows Server in this authoring session, so the responses are expected examples, not a claim of a completed server deployment.
Comments
Post a Comment