What is ASP.NET Core

ASP.NET Core is .NET's framework for the web. It listens for requests, runs your C# to answer each one, and sends back a page built for that request.

Novice · ASP.NET Core · Web Development · Updated

After this lesson you can

  • Explain what ASP.NET Core does when a browser asks for a page
  • Tell a static website from a dynamic one, and name the kinds of app ASP.NET Core builds

Key takeaways

  • A static website sends the same file to everyone; a dynamic website builds each page with code when the request arrives.
  • ASP.NET Core listens for a request, reads it, runs the C# that answers that address, and sends back the response. You write the C#.
  • Kestrel, ASP.NET Core's built-in web server, waits for requests on your app's port.
  • An MVC app sends back whole HTML pages; a Web API sends back data, as JSON, for another program to show.

The pages you built with HTML, CSS and Bootstrap were static: each page was a file, and the server sent that file to anyone who asked, the same every time. A bookstore can't work that way. Its pages show what's in the database right now: today's prices, the books in stock, your order.

Pages like that are dynamic: a program builds each one when the request arrives. ASP.NET Core is how you write that program in C#.

A framework for the web

ASP.NET Core is a framework: a large set of ready-made code that does the common work of every web app, so you write only what's special about yours. It comes with .NET, so there's nothing extra to install.

When a browser asks for a page, ASP.NET Core:

  1. Listens for the request. Its built-in web server, Kestrel, waits on your app's port.
  2. Reads the request: the address, the query string, any form data.
  3. Picks the C# code that answers that address, and runs it. That's the part you write.
  4. Sends back the response, usually HTML, then waits for the next request.

You write step 3. ASP.NET Core does the rest.

Static or dynamic

Static website Dynamic website
Each page is a file on the server Each page is built by code when it's requested
Everyone gets the same page Pages can show data from a database, or depend on who's signed in
To add a page, add a file To add a hundred product pages, write one page that takes the product's id
products/tablet.html Products/Details/7, Products/Details/8, ...

What ASP.NET Core builds

ASP.NET Core can build several kinds of app. This course uses two:

Kind What it sends back In this course
MVC (Model-View-Controller) Whole HTML pages Now: the next chapters build MVC apps
Web API Data, as JSON, for another program to show Later, behind an Angular front end
Razor Pages Whole HTML pages, one file per page Not covered: a simpler style of MVC
Blazor Interactive pages written in C# Not covered

MVC and Web API apps share most of their parts, so what you learn about controllers now carries straight over to APIs.

Check yourself

2 questions to try on the lesson page.

So what

ASP.NET Core does the plumbing of the web (listening, reading requests, sending responses) so your C# can focus on one question: what should this page show? Next, you'll make your first MVC project and watch it answer.

Key terms

Cheat sheets