Last post Dec 07, 2015 01:03 PM by jbowen014
Dec 07, 2015 06:06 AM|aasantosh|LINK
I want to load all settings key value pair from json file at once and use the settings key value in mvc 6 view page.I would be grateful if best solution is provided.I have a scenerio as below
Dec 07, 2015 01:03 PM|jbowen014|LINK
The first thing to do is to create a C# poco class that contains all of the properties in your appSettings.config file that you want to load. I named my object AppSetings.
Assuming all of your settings are under the property 'AppSettings', add the following to your Startup.cs ConfigureServices method:
In your cshtml views, add the following to the top of the file:
@inject IOptions<AppSettings> AppSettings
And then you can reference your settings in the view via @AppSettings.Value.logo_text.
article provides more details (it was written for Beta 4 but basically still applies).