Window Authentication Enabled, Anonymous Disabled. When a user comes into the site, I check to see if they are a user of the site. If they are not, I want to handle them as Unauthorized. However, Chrome keeps re-prompting them for username and password rather than sending them to an error page. The user should never be prompted for username/password because automatic Windows Auth is on and anonymous is off.
Controller:
public async Task<IActionResult> Login()
{
if (await IsValidUser())
{
return RedirectToAction("Index");
}
else
{
return new UnauthorizedResult();
}
}
Startup
app.UseStatusCodePages(async context =>
{
var response = context.HttpContext.Response;
await context.HttpContext.Response.WriteAsync(
"Status code page, status code: " +
context.HttpContext.Response.StatusCode);
response.Redirect("~/Account/AccessDenied");
});