CustomErrors statusCode 500

  • Thread starter Thread starter Jesse Napier
  • Start date Start date
J

Jesse Napier

I have a customerrors section in web.config something like the following:

<customErrors mode="On" defaultRedirect="/errorPage/errorpage.aspx" >
<error statusCode="404" redirect="/errorPage/errorpage404.aspx" />
<error statusCode="500" redirect="/errorPage/errorpage500.aspx" />
</customErrors>

This works fine, but every exception in the app that isn't a 404 error gets
redirected to the statusCode 500 page which represents an Internal Server
Error. Is this standard?

Why doesn't the defaultRedirect page ever get redirected to?

I have a test page that throws an argumentException and I get redirected to
errorPage500.aspx. I want this type of exception to go to errorPage.aspx
which is the default.

Any help would be appreciated.

Thanks,
Jesse
 
That's because an uncaught exception results in 500 error. The default error
page will be used for errors that do not have a page associated with them,
in your case everything else than 404 and 500.

Jerry
 
Thats what I thought. But can other exceptions result in a 500 error or can
I be confident that any 500 error was an uncaught exception.

I am handling uncaught exceptions in the appliacation_error event and I just
want to make sure that the user gets redirected to a friendly page so I let
the redirection be handled by the custom errors redirection in web.config.

Does that make sense?
 
| Thats what I thought. But can other exceptions result in a 500 error or
can
| I be confident that any 500 error was an uncaught exception.

Generally yes. Under normal circumstances, 500 is thrown via exception. The
second way how you can get 500 is when IIS or ISAPI application fails. But
such situation is not standrd and in such case you cannot catch this
situation, because it's not running.
 
Back
Top