Skip to content
Back to Deployment

Deploying ASP.NET Core Apps

Cross-platform .NET apps as self-contained executables, deploy to Kestrel+Nginx, IIS, or Azure App Service.

PlatformsAdvanced

Why

ASP.NET Core on .NET 8+ is cross-platform with excellent performance (TechEmpower benchmarks). Self-contained publishes include the runtime, so no .NET install needed on the server.

Kestrel is a high-performance web server built-in.

When

Use ASP.NET Core for enterprise C# backends, Windows-to-Linux migration, and high-performance APIs. Choose self-contained for container deploys.

How

1. Publish — dotnet publish -c Release -r linux-x64 --self-contained 2. Run — ./MyApp, Kestrel on port 5000 by default 3. Docker — mcr.microsoft.com/dotnet/aspnet:8.0 runtime image 4. IIS — dotnet publish with web.config, deploy to IIS with ASP.NET Core Module 5. Azure — az webapp up, or deploy from GitHub Actions 6. Nginx — reverse proxy to Kestrel for TLS and static 7. Health — MapHealthChecks("/health") for k8s probes

Example

// Program.cs — minimal API with health check var builder = WebApplication.CreateBuilder(args); builder.Services.AddHealthChecks(); var app = builder.Build(); app.MapHealthChecks("/health"); app.MapGet("/api", () => new { message = "hello" }); app.Run(); # Dockerfile — multi-stage FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build WORKDIR /app COPY *.csproj . RUN dotnet restore COPY . . RUN dotnet publish -c Release -o out FROM mcr.microsoft.com/dotnet/aspnet:8.0 WORKDIR /app COPY --from=build /app/out . EXPOSE 8080 ENTRYPOINT ["dotnet", "MyApp.dll"] # appsettings.Production.json { "ConnectionStrings": { "Default": "Host=db;Database=myapp;Username=postgres" }, "Logging": { "LogLevel": { "Default": "Warning" } } }

Common Problems

  • ⚠Runtime missing on server — framework-dependent deploy without .NET installed, use --self-contained
  • ⚠IIS 502.5 — ASP.NET Core Module not installed or wrong processPath in web.config
  • ⚠Kestrel port conflict — default 5000 taken, set ASPNETCORE_URLS=http://+:8080

Best Practices

  • ✓Use --self-contained for container deploys — no runtime dependency on host, fully portable image
  • ✓Enable response compression and static file caching in Production — significant perf gains
  • ✓Set up health checks and graceful shutdown — handle SIGTERM to drain in-flight requests before exit

FAQ