LearnAI ToolsCareerPractice BuildsPlayContact
Lesson 6620 min read

Deploying an ASP.NET Core App

Learn how to publish and deploy an ASP.NET Core application, including Docker containerization.

Publishing Your App

`dotnet publish` compiles an optimized, deployment-ready build of your application.

dotnet publish -c Release -o ./publish

This produces a self-contained folder you can copy to a server and run with `dotnet YourApp.dll`.

Containerizing with Docker

Docker packages your app with everything it needs to run consistently across any environment — a standard approach for modern ASP.NET Core deployment.

Dockerfile
FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS base
WORKDIR /app
EXPOSE 8080
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
WORKDIR /src
COPY . .
RUN dotnet publish -c Release -o /app/publish
FROM base AS final
WORKDIR /app
COPY --from=build /app/publish .
ENTRYPOINT ["dotnet", "TaskApi.dll"]
docker build -t taskapi .
docker run -p 8080:8080 taskapi

Hosting Options

PlatformBest For
Azure App ServiceFully managed, deep integration with the .NET ecosystem
AWS / Google CloudCloud-agnostic, containerized deployments
A VPS with DockerFull control, cost-effective for smaller apps
Render / RailwaySimple, developer-friendly platforms with free tiers for learning

Production Checklist

  • Set ASPNETCORE_ENVIRONMENT to Production.
  • Store secrets in environment variables or a secrets manager, never in source control.
  • Enable HTTPS and HSTS.
  • Run pending EF Core migrations against the production database.
  • Set up logging and monitoring for errors in production.

FAQs

No — you can deploy the published output directly to many hosts. Docker is popular because it guarantees consistency between your local environment and production.

Summary

  • dotnet publish produces an optimized, deployable build.
  • Docker packages your app for consistent deployment anywhere.
  • Always separate environment-specific config and secrets from source control before going to production.

C# & .NET Course Completed!

You have successfully completed all 66 lessons — from C# fundamentals and Object-Oriented Programming through to building, securing, and deploying real ASP.NET Core web applications with Entity Framework Core. You now have a genuinely full-stack C# skill set.

Browse All Courses →