Open
Description
Could you change the initialization of the options from the constructor into Invoke()
?
The reason behind is that in the property Value
the Options is initialized inside the constructor, but if the property access would be done in Invoke()
the initialization will be during a request.
public class RequestLocalizationMiddleware
{
private readonly IOptions<RequestLocalizationOptions> _options;
public RequestLocalizationMiddleware(RequestDelegate next, IOptions<RequestLocalizationOptions> options)
{
_options = options;
}
public async Task Invoke(HttpContext context)
{
var options = _options.Value; // Now the value is created here instead of the constructor
}
}
See
In my case I load the options from a database and I do not want to do it during startup ... and I cannot change that.