How to Read ConnectionString or AppSettings from appsettings.json in .net Core
In this article we are going to see how to read ConnectionString or AppSettings from appsettings.json in .net Core application
If you are already familiar with .net frameworks than you have noticed that in .net Core, Microsoft has changed the configuration file in web applications. Previously it was web.config which is XML based configuration file, and now in .net core they have replaced web.config with appsettings.json which is JSON based configuration file.
The image you are looking is the image of appsettings.json which is present in .net core application.
Now we will see that how to fetch Connection string and AppSettings
Here I am taking an example of Asp.net Core 3.1 WebApi
First you have import namespace
Second you have to inject IConfiguration into the Controller’s contructor
In this step we are going to fetch Connectionstring of the “DefaultConnection”.
In this step we are going to fetch AppSetting of the “Token”.