appsettings.json

  "MyCar": {
    "Color": "blue",
    "Model": "Mazda"
  },

MyController.cs

using Microsoft.Extensions.Configuration;

private IConfiguration Configuration;

public MyController.(IConfiguration _configuration)
{
     Configuration = _configuration;
}
string carColor = Configuration["MyCar:Color"];
string carModel = Configuration["MyCar:Model"];
Last modified: March 14, 2021

Author

Comments

Write a Reply or Comment