Microsoft’s ASP.Net Core is an open-source, cross-platform, lean, and modular framework for building high-performance, scalable web applications. Configuration data in ASP.Net Core is stored as key-value pairs, and can be organized in a multi-level manner. In this article, we will create a new ASP.Net Core project and then use this project to examine how we can work with configuration data in an ASP.Net Core application.
Create a new ASP.Net Core project
To create a new ASP.Net Core project, follow the steps outlined below. Note that this post assumes that you have Visual Studio 2017 installed in your system.
- Open Visual Studio 2017 IDE.
- Click on File > New > Project.
- Select “ASP.Net Core Web Application (.Net Core)” from the list of the templates.
- Specify a name for the project.
- Click OK.
- Select “API” in the “New .Net Core Web Application…” window.
- Select the version of ASP.Net Core you would like to use from the drop-down list at the top.
- Uncheck the “Enable Docker Support” and “Configure for HTTPS” options.
- Select “No Authentication” as we won’t be using it either.
- Click OK.
A new ASP.Net Core project will be created. Note that when a new ASP.Net Core project is created, two files — namely, appsettings.json and appsettings.Development.json — will be configured. Another point to note here is that beginning with ASP.Net Core 2.0, configuration data can now be configured in Program.cs. You are no longer constrained to specify configuration data only in the Startup.cs file. Here is how your Program.cs file will look in ASP.Net Core 2.1: