In my startup.cs in the method public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory) I want to access the HttpContext.
The reason I want to do this is that I want to redirect a 401 response to a login page.
app.UseStatusCodePages(async context => {
var request = context.HttpContext.Request;
var response = context.HttpContext.Response;
if (response.StatusCode == (int)HttpStatusCode.Unauthorized)
// you may also check requests path to do this only for specific methods
// && request.Path.Value.StartsWith("/specificPath")
{
response.Redirect("/account/login");
}
});
context in the above example does not have an HttpContext property. How do I get access to the HttpContext?