Skip to content

4.1 — What ASP.NET Core Is

← Roadmap · Section: 4. Fundamentals and Application Startup Prev: 3.10 Release cadence · Next: 4.2 Hosting model

Markers: 🔥 · Confidence: 🔴 · Last reviewed: —


TL;DR

ASP.NET Core is Microsoft's framework for building web applications and APIs. It is a complete rewrite of the old ASP.NET — cross-platform, much faster, and no longer tied to IIS or to Windows.

  • The old ASP.NET was built on System.Web, a library welded to IIS. ASP.NET Core threw that away entirely.
  • Everything is now opt-in. You add the pieces you want rather than starting with everything switched on.
  • Dependency injection and configuration are built into the framework, not bolted on afterwards.

Definitions

Term What it is What it means
ASP.NET Core a web framework The library set for building web apps and APIs on .NET. Runs on Windows, Linux and macOS.
ASP.NET (classic) the old web framework The 2002–2019 version, built on System.Web. Windows and IIS only. Now legacy.
System.Web an old assembly The classic framework's core library. Contained HttpContext, session, the page lifecycle. Does not exist in ASP.NET Core.
Kestrel a web server The cross-platform HTTP server built into ASP.NET Core. Your app hosts it directly.
Middleware a pipeline component A piece of code that handles a request and can pass it along. See 5.1.
Host the object that runs your app Owns the server, dependency injection, configuration and logging, and manages startup and shutdown.
HttpContext a class Everything about the current request and response. Exists in both frameworks but is a different, lighter type in Core.
Web API a project type An app that returns data (usually JSON) instead of HTML pages.
Razor Pages a project type Page-focused server-rendered HTML. The modern replacement for Web Forms.
Blazor a project type Building interactive UI in C# instead of JavaScript.
Minimal API a style Defining endpoints as lambdas in Program.cs rather than in controller classes.

The concept

What problem it solves

A web application needs to do a lot of plumbing before it does anything useful. Accept TCP connections, parse HTTP, decide which code handles which URL, read configuration, write logs, handle authentication, serialise responses.

ASP.NET Core provides all of it, so you write the part that is actually your application.

Why it was rewritten

The classic ASP.NET was built in 2002 on an assembly called System.Web. That assembly was fused to IIS — Microsoft's Windows web server. Not "designed for" it: fused to it. You could not separate them.

That created three problems that could not be fixed incrementally.

It could only run on Windows. IIS is a Windows product. As the industry moved to Linux servers and containers, ASP.NET could not follow.

It was heavy. Every application loaded the entire framework whether it used it or not — session state, the page lifecycle, view state, all of it. You paid for features you had never heard of.

It shipped inside Windows. New features arrived with Windows updates rather than with your application, so you waited on the operating system's release schedule.

So Microsoft rewrote it. ASP.NET Core has no System.Web at all. The whole framework is a set of NuGet packages your app references, and it hosts its own web server.

A picture: the old ASP.NET was a house built into a specific plot of land. You could not move it. ASP.NET Core is a caravan — it carries what it needs and can park anywhere.


How it works

The simple version — what actually changed

ASP.NET (classic) ASP.NET Core
Runs on Windows only Windows, Linux, macOS
Web server IIS only Kestrel, and optionally behind IIS or Nginx
Ships with Windows Your application, as NuGet packages
Features All loaded, always Opt-in — you add what you use
Dependency injection Third-party, bolted on Built in
Configuration web.config (XML) appsettings.json and many providers
Request pipeline HttpModules and HttpHandlers Middleware
Open source No Yes
Speed Slower Roughly 10× faster on common benchmarks

How it actually works — "everything is opt-in"

This is the change you feel most day to day.

In classic ASP.NET, a new project arrived with session state, authentication, view state and the full page lifecycle already running. Turning things off meant editing web.config and hoping.

In ASP.NET Core you start with almost nothing and add what you need:

var builder = WebApplication.CreateBuilder(args);

// Nothing is on by default. You add each capability deliberately.
builder.Services.AddControllers();          // want controllers? add them
builder.Services.AddAuthentication();       // want auth? add it

var app = builder.Build();

app.UseHttpsRedirection();                  // want HTTPS redirect? add it
app.UseAuthentication();                    // order matters here — see 5.2
app.UseAuthorization();

app.MapControllers();

app.Run();

Every line is a decision. Nothing you did not ask for is running.

The benefit is not only performance — it is that you can see the whole application's behaviour in one file. In classic ASP.NET, behaviour came from web.config, from Global.asax, from IIS settings and from machine-level config, and tracking down why something happened meant checking four places.

The two halves of Program.cs

Notice the shape above. There are always two phases, separated by builder.Build():

var builder = WebApplication.CreateBuilder(args);

// PHASE 1 — REGISTER. What services exist?
builder.Services.AddSomething();

var app = builder.Build();      // ← the dividing line

// PHASE 2 — CONFIGURE. What happens to a request?
app.UseSomething();

app.Run();

builder.Services.Add... says what is available. app.Use... says what happens, and in what order. Confusing the two is the single most common beginner mistake, and after Build() is called you cannot add more services.

Covered properly in 4.3.

The deeper detail — what is gone and what replaced it

If you have classic ASP.NET experience, these are the things that will not be there:

Gone Replaced by
System.Web Nothing — the whole model changed
Web Forms, .aspx, view state Razor Pages, Blazor
HttpModules, HttpHandlers Middleware (5.1)
Global.asax Program.cs
web.config appsettings.json (7.1)
HttpContext.Current (static) Injected IHttpContextAccessor (21.12)
Session, on by default Opt-in, and usually avoided in APIs
Server.MapPath IWebHostEnvironment.ContentRootPath

HttpContext.Current deserves a note. In classic ASP.NET it was a static property you could reach from anywhere. Convenient, and a design flaw — it made code untestable and tied every layer to the web. ASP.NET Core removed it. If you genuinely need the context outside a controller you inject IHttpContextAccessor, and needing it is usually a hint that something should have been passed as a parameter instead.

The project types

ASP.NET Core is one framework covering several kinds of application:

  • Web API — returns JSON. The most common today.
  • MVC — server-rendered HTML with controllers and views.
  • Razor Pages — server-rendered HTML, organised per page rather than per controller.
  • Blazor — interactive UI written in C#.
  • gRPC — high-performance binary APIs between services.
  • Minimal APIs — endpoints as lambdas, no controllers.

They share the same host, the same dependency injection, the same middleware pipeline and the same configuration. Learning the fundamentals once covers all of them, which is why sections 4 to 8 of this roadmap matter more than any individual project type.


Code

The smallest complete ASP.NET Core application:

var builder = WebApplication.CreateBuilder(args);
var app = builder.Build();

app.MapGet("/", () => "Hello World!");

app.Run();

Four lines, and that is a real web server. Compare with classic ASP.NET, which needed a Global.asax, a web.config, a project structure and IIS configured to host it.

A realistic Web API startup, which is what you will actually see:

var builder = WebApplication.CreateBuilder(args);

// ---- Phase 1: register services ----
builder.Services.AddControllers();
builder.Services.AddDbContext<AppDbContext>(o =>
    o.UseSqlServer(builder.Configuration.GetConnectionString("Default")));
builder.Services.AddScoped<IOrderService, OrderService>();
builder.Services.AddAuthentication().AddJwtBearer();
builder.Services.AddAuthorization();

var app = builder.Build();

// ---- Phase 2: build the request pipeline ----
if (app.Environment.IsDevelopment())
    app.MapOpenApi();                       // only expose the API schema in dev

app.UseHttpsRedirection();
app.UseAuthentication();                     // who are you?
app.UseAuthorization();                      // are you allowed?
app.MapControllers();

app.Run();

Everything the application does is visible in that one file. That readability is a deliberate design goal, and it is genuinely one of the strongest arguments for ASP.NET Core over what came before.


Interview questions

Q: What is ASP.NET Core and how does it differ from ASP.NET?

ASP.NET Core is Microsoft's web framework for building applications and APIs on .NET. It is a complete rewrite rather than an upgrade. The classic ASP.NET was built on System.Web, an assembly fused to IIS, which meant it only ran on Windows and always loaded the entire framework whether you used it or not. ASP.NET Core removed System.Web entirely, ships as NuGet packages with your application, hosts its own cross-platform server in Kestrel, and makes every feature opt-in. It also has dependency injection and configuration built into the framework rather than bolted on, and it is roughly ten times faster on typical benchmarks.

Q: Why was it rewritten rather than improved?

Because the problems were architectural. System.Web was fused to IIS, so cross-platform support was not something you could add — it would have meant replacing the foundation. The same applied to the always-on feature set and to shipping inside Windows, which tied the release schedule to the operating system. Fixing any of those meant a new foundation, so Microsoft built one and kept the good ideas.

Q: What happened to HttpContext.Current?

It is gone. In classic ASP.NET it was a static property reachable from anywhere, which was convenient and a genuine design flaw — it made code impossible to unit test and coupled every layer to the web. ASP.NET Core has no static context. If you truly need the request context outside a controller you inject IHttpContextAccessor, but needing it usually indicates that the value should have been passed as a parameter instead.

Q: What replaced HttpModules and HttpHandlers?

Middleware. In classic ASP.NET the pipeline was configured through modules and handlers registered in web.config, with an execution order that was hard to see. In ASP.NET Core the pipeline is built explicitly in Program.cs with a sequence of app.Use... calls, so the order is visible in the code, and each piece of middleware decides whether to pass the request on or short-circuit it.


Traps ⚠️

  • "ASP.NET Core is ASP.NET with a new version number." It is a rewrite. System.Web does not exist, and code depending on it will not port.
  • The name is confusing. The runtime dropped "Core" at .NET 5, but ASP.NET Core kept it. ASP.NET Core 10 runs on .NET 10.
  • Nothing is on by default. Forgetting app.UseAuthentication() means User is never populated and authorization silently fails.
  • Service registration must happen before builder.Build(). Adding after throws.
  • Web Forms did not port and never will. Migrating means rewriting the UI.
  • Session exists but is opt-in and rarely right for APIs. It makes your app stateful, which breaks horizontal scaling (24.12).


Sources