Redirect to user page "Access denied" for ASP.NET kernel

I am writing an ASP.NET Core 1.0 website that uses Windows authentication. I logged in and is working as expected. Currently, when authentication fails for a given user, a shared page with the "HTTP 403" error is displayed.

enter image description here

How do I configure ASP.NET Core to redirect to my own "access denied" page?

I tried the approach described in this article, but it didn’t work for me (perhaps because I use Windows Auth instead of Forms Auth?) How to redirect unauthorized users using ASP.NET MVC 6

Any help would be appreciated.

+4
1

.

app.UseStatusCodePages(async context => {
  if (context.HttpContext.Response.StatusCode == 403)
  {
     // your redirect
  }
});

app.UseStatusCodePagesWithRedirects. ( URL-), URL-. , ~/errors/403 403:

app.UseStatusCodePagesWithRedirects("~/errors/{0}");
+8

Source: https://habr.com/ru/post/1648578/


All Articles