In .Net Core MVC, I'm trying to get value from app settings to MyController by implementing the below code:
public MyController(IConfiguration config)
{
_config = config;
}
private string ApiKey = _config.GetValue<string>("ApiKey");
But I get the below error:
A field initializer cannot reference the non-static field, method, or property 'NafathController._config'