Deployment to IIS, Kestrel, Nginx, Docker

๐Ÿ’ก Concept Name

ASP.NET Core Deployment Options

๐Ÿ“˜ Quick Intro

Deployment is the final step to make your ASP.NET Core application available to users. Depending on the target environment (Windows, Linux, or containerized infrastructure), you may use IIS, Kestrel, Nginx, or Docker.

๐Ÿง  Analogy / Short Story

Imagine you're launching a food truck. IIS is like a food court manager on Windows who organizes your stall. Kestrel is your core cooking setup. Nginx is like a front receptionist redirecting people. Docker is your entire food truck that can be placed anywhere. Each option serves your food (app) differently but ensures customers are served.

๐Ÿ”ง Technical Explanation

  • IIS (Windows): Uses ASP.NET Core Module to reverse-proxy to Kestrel. You install Hosting Bundle and configure the site in IIS.
  • Kestrel: Cross-platform web server used by default. Use it standalone or behind a reverse proxy.
  • Nginx (Linux): Reverse proxy to Kestrel for security and load balancing. Configure `.conf` file and point it to your running app.
  • Docker: Package your app into a container. Platform-agnostic and best for microservices. Run using `docker run` or deploy on Kubernetes.

๐ŸŽฏ Purpose & Use Case

  • โœ… Deploy apps to Windows Server using IIS
  • โœ… Host lightweight APIs with just Kestrel
  • โœ… Reverse proxy on Linux using Nginx
  • โœ… Containerize and scale via Docker/Kubernetes
  • โœ… Run secure apps with HTTPS and load balancing

๐Ÿ’ป Real Code Example

Dockerfile for ASP.NET Core App:


FROM mcr.microsoft.com/dotnet/aspnet:6.0 AS base
WORKDIR /app
EXPOSE 80

FROM mcr.microsoft.com/dotnet/sdk:6.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", "MyApp.dll"]

This Dockerfile builds and runs your ASP.NET Core app in a container using the .NET runtime image.

โ“ Interview Q&A

Q1: What is Kestrel in ASP.NET Core?
A: It's the built-in cross-platform web server.

Q2: Why use Nginx with Kestrel?
A: For reverse proxy, load balancing, and better security on Linux.

Q3: What is the ASP.NET Core Hosting Bundle?
A: A package that includes the .NET runtime and the IIS integration module.

Q4: What is the benefit of using Docker for deployment?
A: Portability, consistency, and isolation of app environments.

๐Ÿ“ MCQs

What is Kestrel in ASP.NET Core?

  • A. Windows Service
  • B. Linux Daemon
  • C. Built-in Web Server ✓
  • D. Docker Container

Which server is typically used as a reverse proxy in Linux deployments?

  • A. Apache
  • B. Kestrel
  • C. IIS
  • D. Nginx ✓

What does the Hosting Bundle install?

  • A. Only .NET Runtime
  • B. Only IIS
  • C. .NET Runtime and ASP.NET Core Module ✓
  • D. SQL Server and IIS

What command is used to publish an ASP.NET Core app?

  • A. dotnet publish ✓
  • B. dotnet deploy
  • C. dotnet serve
  • D. dotnet push

Which Docker instruction sets the entry point?

  • A. START
  • B. CMD
  • C. ENTRYPOINT ✓
  • D. RUN

๐Ÿ’ก Bonus Insight

You can host ASP.NET Core on Azure App Service, which abstracts all underlying infrastructure. It internally uses Kestrel + IIS for Windows or Kestrel + reverse proxy for Linux plans.

๐Ÿ“„ PDF Download

Need a handy summary for your notes? Download this topic as a PDF!

โžก๏ธ Next:

๐Ÿ’ฌ Feedback
๐Ÿš€ Start Learning
Share:

Tags: