Reputation: 2785
How can I make it return a custom ASP.NET page with an error code of 404? Currently it doesn't do that when I set the
<customErrors mode="On">
<error statusCode="404" redirect="~/UtahDisclosures.aspx" />
</customErrors>
Upvotes: 1
Views: 1044
Reputation: 3141
This seems to be a quirk of ASP.NET and one that I was unnaware of before reading your post.
However, a quick Google turned up this blog post: http://www.digitallycreated.net/Blog/57/getting-the-correct-http-status-codes-out-of-asp.net-custom-error-pages
They seem to know what they're on about and suggest using this:
<% Response.StatusCode = (int)HttpStatusCode.NotFound; %>
along with some other key steps (see the link).
Also, when sending custom error pages, you might need to bear this IE minimum error page size quirk in mind.
Upvotes: 2