Exploring an ASP.NET Core MVC website
Let’s walk through the parts that make up a modern ASP.NET Core MVC website.
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 a<Main>$
method). This file can be considered to be divided into four important sections from top to bottom. As you review the sections, you might want to add comments to remind yourself of what each section is used for..NET 5 and earlier ASP.NET Core project templates used a
Startup
class to separate these parts into separate methods, but with .NET 6 and later, Microsoft encourages putting everything in a singleProgram.cs
file.
- The first section imports some namespaces, as shown in the following code:
// Section 1 - import...