Question

I want to have control over my Http Exceptions to the point of being able to dictate what is in the body of the response. If I throw a standard HttpException(404, "not found"); then using fiddler I can see the 404 status code is set but there is all this garbage html thats shoved into the response body.

Is there any way to override or extend the HttpException class to allow you to inject your own content into the response body?

I have attempted to implement my own CustomHttpException that like the HttpException extends the ExternalException class but no matter how I cut it the system always throws a 500 error with the same standard html in the body.

Any help?

Was it helpful?

Solution

No, no, no.

Take a look at CustomErrors.

Basically you do something like this

    <customErrors defaultRedirect="GenericError.htm"
                  mode="RemoteOnly">
       <error statusCode="404"
              redirect="NotFound.aspx"/>
    </customErrors>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top