Manidas Payyoli

Manidas Payyoli

  • 1.4k
  • 589
  • 155.8k

Not Getting Appsetting value to start up.cs?How to do that?

Jun 15 2021 7:46 AM

I have gone through enough article and tried different inplimentations but i coudnt get appsetting value.I am using .net core 5.0 What i have done is below.onlu NULL i am getting

My appsetting.json

{
  "Logging": {
    "IncludeScopes": false,
    "LogLevel": {  
      "Microsoft": "Information"
    }
  },
  "AzureDevopsUri": "https://dev.azure.com"
}

My startup.cs

public class Startup
{
    // requires using Microsoft.Extensions.Configuration;
    private readonly IConfiguration Configuration;

    public Startup(IConfiguration configuration)
    {
        Configuration = configuration;
    }

    public void ConfigureServices(IServiceCollection services)
    {
        string azureDevopsUri = GetConfig("AzureDevopsUri");
    }

    private string GetConfig(string configKey)
    {
        var configValue = Configuration[configKey];  // coming NULL here 
    }
}

 


Answers (6)