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 startup
Appropriately enough, we will start by exploring the MVC website's default startup configuration:
- Open the
Startup.cs
file. - Note the read-only
Configuration
property that can be passed in and set in the class constructor, as shown in the following code:public Startup(IConfiguration configuration) { Configuration = configuration; } public IConfiguration Configuration { get; }
- Note that the
ConfigureServices
method adds an application database context using SQLite with its database connection string loaded from theappsettings.json
file for its data storage, adds ASP.NET Core Identity for authentication and configures it to use the application database, and adds support for MVC controllers with views, as shown in the following code:public void ConfigureServices(IServiceCollection...