Hello friends, welcome to the next lecture. In this lecture, we will learn the significance of upsetting dot JSON file. Now, in previous lab, we will see what is the use of launch settings dot JSON file. In this lecture, we will learn what is the user actually dot JSON file. Now, you can see absolutely not Jason under the app setting dot development dot Jason. If your environment is staging then this file will be at settings dot staging dot JSON.
Okay, now we are on a development more. So we use that settings not development but just a If you remember, in our previous dotnet version, we use web config file, what configuration to store the configuration in that find, but in ASP NET Core, there is no web dot config file. So, where we can store the configuration information about the product you can store first. No, absolutely. Okay. After that you can store it isn't user secret 31 is an environment variable.
Now, if I want to pass the configuration from command line, is that available? Yes, it is also. No, we see how to fill but how to configured our project. Now, I'm going to add that city in here. Right one key support key. And here I APN No, no, I want to read this key.
Okay, how I do that? If you find the startup class, in previous labs, we learn what is the startup class. What's the use of that startup class. Now you can see it is a constructor. It is by Default given by dotnet core framework. And here one is our configuration and the object of that configuration.
Here, use dependency injection, and we assign value of that configuration to our configuration variable. Now, if you want to read the configuration settings from the respective files, you use PI configuration. Okay? Remember, you can use a configuration object. Now I want to check the value of this key. How am I going to do that?
Simply, here, we can write, configuration and key Key key if I run this program what will know? Now it's running. Now you can see data APA capturing dot Jason file if we see here key data Yeah, no, actually I didn't know just know if I want to use the same variable on our development setting file. So right here, actually, Doc development Okay, I refresh this page you can see now it's returning absent in development. You can store this information on environment variables. Now, environment variable present in a long setting dot Jason here.
You no I want to refresh this Nothing is happening, why we need to be live again. Now it's building. Okay, now you can see it from environment wherever. Now I want to pass the information prompt command line. How am I going to do that by simply This is our developer command prompt. In this we have dotnet parameter and I want to pass the command line argument.
So, I use command line argument as my key data flow command line, press Enter. Now it's building program Okay. Now it is listening on photos input into the coppins text and here simply goes here. And if I press now you can see data from coming in. So what is the secret? How to Read the configuration data?
First, always remember, it reads Have not sitting tight. If the same key is found in a respect to version, environment version means development staging production, then it overrides that absolutely setting value by way of setting development JSON file if the same key and you know, environment variable, then it over it that also and after on the command line. So that's all about upsetting. Remember only one thing. App setting is used to save the configuration related thing like our web config. And for reading this, we use eye configuration and dependency injection is used here.
So thank you for watching. We will be in a next slide.