ASP.NET Core Deployment

Overview

Deploying an ASP.NET Core application involves preparing your app for a target environment, selecting a hosting model, and publishing the final output. ASP.NET Core supports a variety of deployment targets including Windows IIS, Linux Nginx, Docker containers, Azure App Service, and self‑contained executables.

Prerequisites

Publish Methods

Folder Deployment

dotnet publish -c Release -o ./publish

Docker Container

FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS base
WORKDIR /app
EXPOSE 80
COPY . .
ENTRYPOINT ["dotnet","MyApp.dll"]

Azure App Service

Use the az webapp up command or deploy via GitHub Actions. See Azure deployment guide.

IIS Hosting

Publish as a self‑contained deployment and configure the web.config automatically. See Deploy to IIS.

CI/CD Integration

Configure your pipeline to build and publish on each commit.

GitHub Actions Example

name: Build and Deploy
on:
  push:
    branches: [ main ]
jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
      - name: Setup .NET
        uses: actions/setup-dotnet@v3
        with:
          dotnet-version: 8.0.x
      - name: Restore
        run: dotnet restore
      - name: Build
        run: dotnet build --configuration Release --no-restore
      - name: Publish
        run: dotnet publish -c Release -o ./publish
      - name: Deploy to Azure Web App
        uses: azure/webapps-deploy@v2
        with:
          app-name: my-aspnetcore-app
          publish-profile: ${{ secrets.AZURE_WEBAPP_PUBLISH_PROFILE }}
          package: ./publish

Frequently Asked Questions

Do I need to install the .NET runtime on the target server?

If you publish a self‑contained deployment, the runtime is bundled with your app and no additional installation is required.

How do I enable HTTPS?

Configure your reverse proxy (IIS, Nginx, Apache) to terminate TLS and forward requests to the Kestrel server, or use the UseHttpsRedirection middleware in Program.cs.