Copied to clipboard

Flag this post as spam?

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


  • Dalton Kirk 1 post 22 karma points
    Aug 10, 2022 @ 09:34
    Dalton Kirk
    1

    UseExceptionHandler does not work with RenderControllers

    Hello,

    I have a page in my Umbraco site that uses the standard RenderController and I can access it with the path /500

    Now I want to setup the Exception Hanlder middleware to show this page in the event of an internal server error.

    So I add this to my startup.cs:

    public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
        {
            app.UseExceptionHandler("/500");
            ...
    

    Then I throw a new exception on my homepage controller to test this out. In the console, I get an error saying the Exception handler returned a 404 but this is not allowed.

    We can get around this by allowing 404s on the exception handler with this:

                app.UseExceptionHandler(
                    new ExceptionHandlerOptions()
                    {
                        AllowStatusCode404Response = true,
                       ExceptionHandlingPath = "/500",
                   }
                );
    

    But then I get the blank browser default 404 error page. Because the issue is that it can not find my page so it can't display it.

    If I set the Exception Handling Path to a static .HTML file or a SurfaceController or a custom controller with a custom route, it works.

    It just does not work when you point to a RenderController.

    I feel like this is something it should be able to handle.

    Any advice appreciated!

Please Sign in or register to post replies

Write your reply to:

Draft