I have a controller EBisUserController which contains a public property ConnectionString obtained from appsettings.json through dependency injection. The controller has an attribute filter 'EBisUserAuthResourceFilter' requiring use of the property ConnectionString found in the controller. What is the most performant method to access ConnectionString. I have a working example of what I want, but know this is not the correct way of doing this as it must open and read the file for each transaction.
public class EBisUserAuthResourceFilter : Attribute, IResourceFilter {
private string _connectionString;
public EBisUserAuthResourceFilter() {
var builder = new ConfigurationBuilder()
.SetBasePath(Directory.GetCurrentDirectory())
.AddJsonFile("appsettings.json");
_connectionString= builder.Build().GetValue<string>("Data:DefaultConnection:ConnectionString"); //this property exists as property of controller through DI, how can we access it?
}
}