473,396 Members | 2,039 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,396 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 1430
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
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.