.NET core app config

Config file

Add custom appsettings.json like "ELKServerSetting.json" in project.

Config:


1
2
3
4
5
6
7
8
9
{
  "ELK": {
    "url": "http://localhost:9200",
    "indexes": {
      "userIndex": "user-log",
      "webApiIndex": "webapi-log"
    }
  }
}

Code to read config:


1
2
3
  using (var httpRequest = new HttpRequestMessage(HttpMethod.Post, $"{ConfigurationManager.AppSetting["ELK:url"]}/{ConfigurationManager.AppSetting[documentType]}/documents/"))
  {
  }

No comments:

Post a Comment

Move Github Sub Repository back to main repo

 -- delete .gitmodules git rm --cached MyProject/Core git commit -m 'Remove myproject_core submodule' rm -rf MyProject/Core git remo...