Exploring an ASP.NET Core MVC website
Let's walk through the parts that make up a modern ASP.NET Core MVC website.
Understanding ASP.NET Core MVC initialization
Appropriately enough, we will start by exploring the MVC website's default initialization and configuration:
- Open the
Program.cs
file and note that it uses the top-level program feature (so there is a hiddenProgram
class with aMain
method). This file can be considered to be divided into four important sections from top to bottom..NET 5 and earlier ASP.NET Core project templates used a
Startup
class to separate these parts into separate methods but with .NET 6, Microsoft encourages putting everything in a singleProgram.cs
file. - The first section imports some namespaces, as shown in the following code:
using Microsoft.AspNetCore.Identity; // IdentityUser using Microsoft.EntityFrameworkCore; // UseSqlServer, UseSqlite using Northwind.Mvc.Data; // ApplicationDbContext...