Global Error Handler

  • Thread starter Thread starter Samuel Shulman
  • Start date Start date
S

Samuel Shulman

Hi all

I would like to implement a Global Error Handler for the following reasons

1. Redirect all users to that page so they will not be lost

2. Learn of the error and fix it...

Somthing similar to the one used in VB applications

Thank you,
Samuel
 
Here is what I have...

in global.asax.cs

protected void Application_Error(Object sender, EventArgs e)
{
Message.LastException = Server.GetLastError().GetBaseException();
string message = "whatever you want to put in here, such as pageurl,
lastexception.message etc.";
}


in your web.config
change the customErrors line to be...

<customErrors mode="On" defaultRedirect="errorpage.aspx" />

in your errorpage...

if (Message.LastException != null)
{
Response.Write(Message.LastException.Message.ToString());
}

You can then display a friendly error message and send the message to
yourself in email.

Actually, looking at this, I don't know why I have string message=... in my
global.asax.cs.

Regards,
Dave Colliver.
http://www.AshfieldFOCUS.com
~~
http://www.FOCUSPortals.com - Portal franchises available
 
Thank you for your respose,

What is the type of 'Message.LastException'
and where is it declared>

Cheers,
Samuel
 
I managed

Thank you

Samuel

Samuel Shulman said:
Thank you for your respose,

What is the type of 'Message.LastException'
and where is it declared>

Cheers,
Samuel
 
Back
Top