Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • NPina 32 posts 183 karma points
    May 24, 2023 @ 17:18
    NPina
    0

    How to implement custom page for /Account/AccessDenied route

    Hello,

    I would like to know if there is any way to implement a custom page that umbraco will use when session is expired to redirect the user.

    Thanks,

    NPina

  • Huw Reddick 1929 posts 6717 karma points MVP 2x c-trib
    May 25, 2023 @ 12:51
    Huw Reddick
    0

    you could do so ething like below.

    Add this in startup.cs

        if (env.IsDevelopment())
        {
            ...
        }
        else
        {
            app.UseExceptionHandler("/error");
            ...
        }
    

    Then create an error controller

    public class ErrorController : Controller
    {
        [Route("error")]
        public IActionResult Index()
        {
            switch(Response.StatusCode)
            {
                case StatusCodes.Status200OK:
                case StatusCodes.Status500InternalServerError:
                    return Redirect("/500");
                default:
                    return Redirect("/404");
            }
        }
    }
    

    You can add the pages for any of the statuses you require.

Please Sign in or register to post replies

Write your reply to:

Draft