How to handle Error Code Events

G

Guest

Hi,
I developed an ASP.NET application. I am testing my application with all possibility of data. How to handle HTTP errors (Codes) in ASP.NET.
Regards,
Sezhman
 
S

Scott Allen

Hi Sezhman:

Inside of the code behind file for global.asax you'll find an
Application_Error method. From here you can examine run time
exceptions in the application with Server.GetLastError. HttpExceptions
will have a GetHttpCode method, and sometimes you need to look at the
InnerException property of the exeception to find the HttpException.

You can also use web.config to redirect to a custom error page.
See
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnaspnet/html/asp08232001.asp
for more info.

HTH,
 
G

Guest

Try using this in Web.Config file

<customErrors
defaultRedirect = "http://.../DefaultError.aspx mode="on">
<error StatusCode="404" redirect="FileNotFound.aspx">
<error StatusCode="500" redirect="ServerError.aspx">
</customErrors>

I think this is the best way to handle the error code events. I have done this in my work and there is no probs.
 
G

Guest

Try using this in Web.Config file

<customErrors
defaultRedirect = "http://.../DefaultError.aspx mode="on">
<error StatusCode="404" redirect="FileNotFound.aspx">
<error StatusCode="500" redirect="ServerError.aspx">
</customErrors>

I think this is the best way to handle the error code events. I have done this in my work and there is no probs.
 
G

Guest

Try using this in Web.Config file

<customErrors
defaultRedirect = "http://.../DefaultError.aspx mode="on">
<error StatusCode="404" redirect="FileNotFound.aspx">
<error StatusCode="500" redirect="ServerError.aspx">
</customErrors>

I think this is the best way to handle the error code events. I have done this in my work and there is no probs.
 

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

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top