Copied to clipboard

Flag this post as spam?

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


  • Ian Grainger 71 posts 135 karma points
    Sep 26, 2023 @ 14:34
    Ian Grainger
    0

    Official docs 500 error handler returns 302 -> 200

    We've followed the official docs for our Umbraco 11 site - but they use a redirect - which returns a 302 status code, not a 500.

    The page which is redirected to is a normal page - so that then returns a 200.

    This is a problem because all errors in controller code, and APIs will do the same thing - so our code which tries to handle errors from the API will never be hit - they look like 200 responses (with the error page HTML in the response body).

    So the question is: how do I make the custom error page behave correctly and return a 500 status code?

  • Huw Reddick 1929 posts 6697 karma points MVP 2x c-trib
    Sep 27, 2023 @ 10:14
    Huw Reddick
    0

    Hi Ian

    so our code which tries to handle errors from the API

    where and how is your code implemented for this?

  • Ian Grainger 71 posts 135 karma points
    Sep 27, 2023 @ 11:06
    Ian Grainger
    0

    I wasn't clear - I was talking about the client-side code. It uses Request. The response code isn't an error - so the error handling code isn't hit.

  • Huw Reddick 1929 posts 6697 karma points MVP 2x c-trib
    Sep 27, 2023 @ 11:10
    Huw Reddick
    0

    So, how are you trying to handle the errors clientside? You coul try appending the code as a querystring variable and handling that in your error page.

  • Ian Grainger 71 posts 135 karma points
    Sep 27, 2023 @ 11:51
    Ian Grainger
    0

    How would I add to the querystring in the error page? The client makes the request and sets the query string, right?

  • Huw Reddick 1929 posts 6697 karma points MVP 2x c-trib
    Sep 27, 2023 @ 12:18
    Huw Reddick
    0

    I meant, change the redirict in the error controller to maybe

    return Redirect("/statuscodes/500/?" + errocode);
    

    Not really sure what you are trying to achieve, yes, clients make the request, but 500 errors come from the server not the client.

Please Sign in or register to post replies

Write your reply to:

Draft