I have a json configuration file:
{
"chat": {
"host": "http://localhost:4555"
}
}
Also I have created class :
public class ChatConf
{
public String host { get; set; }
}
In my Startup file I'm doing this:
services.AddOptions();
services.Configure<ChatConf>(Configuration.GetSection("chat"));
The question is how can I get value of host in my main Layout?
Thanks.
you need to include Microsoft.Extension.IOption in your controller to work with the IOption collection. Then you can access your class by adding it to the constructor of you controller.
here is a good explanation