.net core configuration

.net core configuration has changed. there will be no more System.Configuration, instead we're gonna be using Microsoft.Framework.Configuration. :)

To summarize how it is different :-

a) Read all configuration (file - json, ini and also environment variables) on Startup (Owin's start up)

b) Also in startup, save settings of your model using ConfigureServices. You model needs to have exact attribute name

c) Expose it in your Controller's constructor via IOptions.

So it takes abit of reading to understand what is going on.


Lets say i have config.json which contains the following contents :




I will create my model to read in these properties as shown here.




Finally in my controller, i have my controller and constructor which looks as follows :-




That's it! :)



Comments

Popular posts from this blog

The specified initialization vector (IV) does not match the block size for this algorithm