CustomErrors statusCode 500

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
 
J

Jerry III

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
 
J

Jesse Napier

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?
 
M

Michal A. Valasek

| 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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top