- Home
- .NET code examples
- Read appsettings.json config in ASP.NET Core
Read appsettings.json config in ASP.NET Core
When developing an ASP.NET Core application, it's important to be able to define a group of settings, and be able to read those settings within the application.
appsettings.json file, and use them in your application
appsettings.json file into a console application.
Software
This is the software that will need to be installed onto your machine.
- Visual Studio 2019. Version 16.8.4 or above (may work with lower versions). It will work with the free community version.
- SQL Server 2017, or above.
- .NET 5.0 SDK, or above.
Get The Application Working
These are the steps to get the application working.
- Fill out the code example form. We will send you an email where you can download the code example.
The ASP.NET Core MVC Application
The ASP.NET Core MVC application is located in the RoundTheCode.AppSettings.Web folder.
RoundTheCode.AppSettings.Web.sln in Visual Studio.
https://localhost:5000.
https://localhost:5000/appsettings/first-wayhttps://localhost:5000/appsettings/second-wayhttps://localhost:5000/appsettings/third-way
If you wish to test out the connection strings, you need to do the following:
- Inside the source code, there is a folder called
Database. Within that folder, there is a file calledRoundTheCodeSync.bak. This needs to be imported as a database into your SQL Server. - Open up
RoundTheCode.AppSettings.Web\ RoundTheCode.AppSettings.Web\ appsettings.jsonand change the connection string that's inConnectionStrings>SyncDb. - Then run the application in Visual Studio and navigate to
https://localhost:5000/appsettings/database.
Console Application
The Console application is located in the RoundTheCode.AppSettings.ConsoleApp folder.
RoundTheCode.AppSettings.ConsoleApp.sln in Visual Studio.
More Information
You can read more information by viewing our "How to Read The appsettings.json Configuration File in ASP.NET Core" article.
appsettings.json file into our ASP.NET Core application.
Give us your anonymous feedback regarding this page, or any other areas of the website.
Watch .NET tutorials
Subscribe to our YouTube channel
Related code examples