Global Error Handler

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
 
G

Guest

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
 
S

Samuel Shulman

Thank you for your respose,

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

Cheers,
Samuel
 
S

Samuel Shulman

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
 

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,755
Messages
2,569,536
Members
45,007
Latest member
obedient dusk

Latest Threads

Top