ASP.NET Core

On this page 7

ASP.NET Core is Microsoft’s open-source, cross-platform web framework for building server-side web applications, HTTP APIs and real-time services on the .NET runtime. In web architecture, it occupies the backend layer: it receives HTTP requests, runs them through a configurable middleware pipeline, executes application code and returns HTML, JSON or streamed responses.

The framework was released in 2016 as a ground-up redesign of the older Windows-only ASP.NET. It runs on Windows, Linux and macOS, ships with its own high-performance web server called Kestrel, and follows the yearly .NET release cadence, with long-term support (LTS) releases every second year.

How the ASP.NET Core request pipeline works

Every ASP.NET Core application is built around a host that configures services, logging and the server, and a request pipeline that processes each incoming request in sequence. The pipeline is composed of middleware components, small units that can inspect the request, act on it, call the next component or short-circuit the chain and respond immediately.

Order matters because each middleware wraps the ones registered after it. Exception handling must come first so that it can catch failures downstream, while authentication must run before authorization, and both must precede the endpoint that serves protected data. A misordered pipeline is one of the most common causes of security gaps and confusing behavior.

The following table lists the main building blocks that a request passes through in a typical deployment.

ComponentRoleTypical configuration
KestrelCross-platform HTTP server inside the processHTTP/1.1, HTTP/2, HTTP/3, TLS
Reverse proxyOptional front server for TLS, load balancing, cachingNginx, IIS, YARP, cloud load balancer
MiddlewareOrdered handlers for cross-cutting concernsExceptions, HTTPS, static files, CORS, auth
RoutingMaps URL and HTTP method to an endpointAttribute or pattern-based routes
EndpointExecutes the application logicController action, Razor Page, minimal API handler
Dependency injection containerCreates and disposes servicesSingleton, scoped or transient lifetimes
Core building blocks of an ASP.NET Core application

Dependency injection is built into the framework rather than added by a library. Services are registered with a lifetime: singleton for one shared instance, scoped for one instance per request and transient for a new instance on every resolution. Injecting a scoped service such as a database context into a singleton is a classic error, because the singleton then holds a stale object across requests.

Programming models in ASP.NET Core

ASP.NET Core offers several programming models on one shared foundation, so teams can mix them inside a single application. All of them use the same routing, middleware, configuration and dependency injection, which keeps cross-cutting behavior consistent.

ModelOutputBest suited for
Minimal APIsJSON over HTTPSmall services, microservices, lean endpoints
MVC controllersJSON or server-rendered viewsLarge APIs with filters and conventions
Razor PagesServer-rendered HTML per pageForm-heavy sites and admin tools
BlazorInteractive components in C#Rich interfaces without a JavaScript framework
SignalRReal-time messages over WebSocketsChat, dashboards, live notifications
gRPCBinary Protocol Buffers over HTTP/2Fast service-to-service communication
Main application models and their typical use

Blazor deserves a note because it blurs the line between frontend and backend. Components can render on the server, run in the browser through WebAssembly, or combine both modes, which lets a C# team build interactive pages while sharing validation and data types with the API layer.

How ASP.NET Core compares with other web frameworks

ASP.NET Core belongs to the same category as Spring Framework, Django, Express.js and Ruby on Rails: a server-side web framework that structures how requests are handled. The differences lie in the language, the runtime model and how much functionality comes built in.

FrameworkLanguage and runtimeConcurrency modelBuilt-in scope
ASP.NET CoreC# on .NETAsync tasks on a thread poolBroad: DI, auth, validation, real time
Spring FrameworkJava or Kotlin on the JVMThread per request or reactiveBroad, modular ecosystem
Express.jsJavaScript on Node.jsSingle-threaded event loopMinimal, relies on packages
DjangoPythonWorker processes, optional asyncBroad, includes ORM and admin
Ruby on RailsRubyWorker processes and threadsBroad, convention over configuration
ASP.NET Core next to common backend frameworks

The async and await model is central to its performance. While a request waits for a database or a remote API, the thread returns to the pool and serves other work, so a modest server can handle thousands of concurrent connections. Independent benchmarks such as TechEmpower regularly place ASP.NET Core among the faster mainstream frameworks, although real applications are usually limited by database access rather than by the framework itself.

Deploying and configuring ASP.NET Core applications

An ASP.NET Core application compiles into a self-contained or framework-dependent deployment that can run as a console process, a Windows service, a Linux systemd unit or a container image. Official .NET container images and the ability to publish trimmed, ahead-of-time (AOT) compiled binaries make it well suited to cloud-native and twelve-factor app designs.

Configuration is layered: values from appsettings.json are overridden by environment-specific files, environment variables, command-line arguments and secret stores. This order lets the same build move unchanged from development to staging and production. The decision table below summarizes common hosting choices.

SituationRecommended setupReason
Containerized microservicesKestrel in a container behind an ingressPortable, scales horizontally
Existing Windows server estateIIS with the ASP.NET Core moduleUses existing management and certificates
Linux virtual machineKestrel behind Nginx as reverse proxyTLS offload and static file caching
Fast cold start requiredNative AOT publish of a minimal APISmaller image, lower startup time
Managed platformCloud app service or serverless containerPatching and scaling handled by the provider
Choosing a hosting approach

Limitations and common mistakes with ASP.NET Core

ASP.NET Core is mature, but its breadth creates typical pitfalls that experienced developers learn to avoid. Most problems come from misunderstanding asynchronous code, service lifetimes or the release model rather than from defects in the framework.

  • Blocking on async code with .Result or .Wait() can exhaust the thread pool and cause request queuing under load.
  • Misordered middleware can leave endpoints unprotected or skip error handling entirely.
  • Ignoring the support lifecycle is risky: standard-term releases receive about 18 months of patches, LTS releases about three years.
  • Native AOT has restrictions: reflection-heavy libraries and some MVC features are not fully supported.
  • Assuming it is the old ASP.NET leads to errors, because Web Forms and the System.Web model do not exist in ASP.NET Core.

The framework also brings a learning curve for teams coming from dynamic languages, since strong typing, dependency injection and the hosting model require more upfront structure than a minimal Express.js or Flask application.

Explained without jargon

When you open a website or an app talks to a server, something on that server has to read the request and decide what to send back. ASP.NET Core is a toolkit for building that something. Programmers write the rules in the C# language, and the toolkit handles the routine work of receiving requests, checking who is asking and sending answers.

Think of it as the kitchen of a restaurant. Orders arrive, pass through stations in a fixed order, such as checking the order, preparing the dish and plating it, and the finished meal goes out. ASP.NET Core provides the kitchen layout and the equipment, while each company decides what is on its menu.

A typical use case

A regional logistics company needs a backend for its customer portal and its drivers’ mobile app. The development team builds one ASP.NET Core service with minimal API endpoints for shipment tracking, SignalR to push live delivery positions to the portal, and JWT bearer authentication shared by the web and mobile clients.

The service is packaged as a Linux container image and deployed to a Kubernetes cluster with three replicas behind an ingress controller. Configuration such as database connection strings comes from environment variables and a secret store, so the same image runs in staging and production.

During the holiday peak, traffic triples to roughly 2,000 requests per second. Because the database calls are fully asynchronous, the cluster scales from three to eight replicas automatically and median response time stays below 80 milliseconds, without any change to the application code.