Mihneas22
Mihneas22
CC#
Created by Mihneas22 on 12/9/2024 in #help
Get values from appsettings in .NET Core
Hello, I have this function in which I try to get a value from app settings file with the IConfiguration but it seems the method I got to use doesen't exist in this current context. How can I solve? private readonly IConfiguration _configuration; public APIKeyValidation(IConfiguration configuration) { _configuration = configuration; } public bool ValidateKey(string userApiKey) { if (userApiKey == null) return false; var apiKey = _configuration.GetValue<string>(ApiConstants.ApiKeyName); if(apiKey == null || userApiKey != apiKey) return false; }
8 replies