473,327 Members | 1,952 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,327 software developers and data experts.

Global Error Handler

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
Nov 16 '06 #1
3 1428
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.ToStr ing());
}

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
"Samuel Shulman" wrote:
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
Nov 16 '06 #2
Thank you for your respose,

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

Cheers,
Samuel
"David Colliver" <Da***********@discussions.microsoft.comwrote in message
news:19**********************************@microsof t.com...
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.ToStr ing());
}

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
"Samuel Shulman" wrote:
>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

Nov 17 '06 #3
I managed

Thank you

Samuel

"Samuel Shulman" <sa************@ntlworld.comwrote in message
news:uc**************@TK2MSFTNGP02.phx.gbl...
Thank you for your respose,

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

Cheers,
Samuel
"David Colliver" <Da***********@discussions.microsoft.comwrote in
message news:19**********************************@microsof t.com...
>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.ToSt ring());
}

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
"Samuel Shulman" wrote:
>>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


Nov 17 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Vish | last post by:
Hi, Could somebody indicate how to write a global error handler for a Class Library in .NET. I have seen numerous examples for Console, Web and Winforms application but unable to find a single...
13
by: deko | last post by:
I use this convention frequently: Exit_Here: Exit Sub HandleErr: Select Case Err.Number Case 3163 Resume Next Case 3376 Resume Next
2
by: Steve Richfield | last post by:
My error handler works GREAT. However, VBA seems to have some bugs/features that are causing it fits. The little snippet that I put at the end of each routine looks like this: Error_Handler: If...
2
by: Win, Pats | last post by:
Sorry if this is OT, I'm not sure where else to research this... I recently added a "global error handler" via an HTTP Module so I could log all otherwise unhandled exceptions. Every day I get...
2
by: Lucas Tam | last post by:
Without writing try/catch statements is there a way to have a global error handler in VB.NET? In ASP.NET there is an application level error handler inside Global.asax, but is there something...
10
by: robert d via AccessMonster.com | last post by:
I have a global error handler that up until today has been working flawlessly. Let me first provide the relevant code **************************************************************** On Error...
2
by: yeghia \(sosy\) | last post by:
Hi Guys I have two questions. 1. Is there a way to set a handler to .NET application so that in case of not caught exception my handler is called before application shutdown. I want to send an...
0
by: jefftheman812 | last post by:
I would like to use a global error handler via the web config file. Setting the error page is easy but I seem to be having issues catching the error in my customized page. Here is the offending...
3
by: Rodrigo Juarez | last post by:
Hi Microsoft Visual Studio 2005, Visual Basic and winforms application I need a global error handler, where should I put that. Any examples? TIA Rodrigo Juarez
1
by: John | last post by:
Hi I have a winform app with try/catch error handling implemented in key areas. Problem is errors can occur in other areas in situations that I may not foresee. Is there a way to implemented a...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.