500 Custom error is never shown but is present in the preview
I've added custom error pages to my project and referenced them in the web.config
following way:
<customErrors mode="On" redirectMode="ResponseRewrite" defaultRedirect="~/Errors/500.aspx">
<error statusCode="404" redirect="~/Errors/404.aspx" />
<error statusCode="500" redirect="~/Errors/500.aspx" />
</customErrors>
When I view a page that does not exist, I see the page 404
rendered as expected.
However, I now have an error in the following method POST
:
CheckRenewalEligibility(string uprn);
When I click the button that triggers this, nothing happens. When I open dev tools in chrome I see:
And then when I click on the red highlighted CheckRenewalEligibility
to see the Preview, it displays my custom error page.
My question is why it doesn't show up in the interface when an error occurs 500
, why it just doesn't do anything.
note I have the aspx and html versions of both custom error pages located in the path Errors
.
source to share
The problem you are having is that you are making your request via AJAX. In these cases, on server side errors, the error pages are displayed but never displayed to the user - this is the AJAX nature.
Since you haven't provided a way to do the AJAX, I'm assuming you are using the popular jQuery. For ajax requests via jQuery, see this answer - explains how to capture server side errors.
source to share
