Skip to content

Latest commit

 

History

History
19 lines (15 loc) · 485 Bytes

asp-net-configuration.md

File metadata and controls

19 lines (15 loc) · 485 Bytes

Configuration in ASP.NET

In ASP.NET Core, IConfiguration is set automatically. Just inject the inteerface into the constructor of your class.

public WebhookController(ILogger<WebhookController> logger, 
    IConfiguration configuration)
{
    _logger = logger;
    _configuration = configuration;
}

private string GetSigningKey(string tenantId)
{
    var key = $"{tenantId.ToUpper()}_ClientKey";
    return _configuration.GetValue<string>(key) ?? string.Empty;
}