473,408 Members | 2,734 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,408 software developers and data experts.

Handling uncaught exceptions

27
Dear Friends,

I'm struggling with my ASP.NET/C# site. I want a default error site for all the uncaught exceptions.

I tried to work it out, but no success.
That's what I did:

Global.asax:
Expand|Select|Wrap|Line Numbers
  1. void Application_Error(object sender, EventArgs e) 
  2.     HttpApplication app = (HttpApplication)sender;
  3.     app.Response.Clear();
  4.     app.Response.Write("hello");
  5. }
  6.  
After this didn't work, I tried to write a pipeline for it:

Web.Config:
Expand|Select|Wrap|Line Numbers
  1.     <httpModules>
  2.       <add name="ErrorHandlerHTTPModule" 
  3.         type="PinsPipeLine.ErrorHandlerHTTPModule, PinsPipeLine" />
  4.     </httpModules>
  5.  
And the Code for it:
Expand|Select|Wrap|Line Numbers
  1.    public class ErrorHandlerHTTPModule : IHttpModule
  2.     {
  3.  
  4.         #region IHttpModule Members
  5.  
  6.         void IHttpModule.Dispose()
  7.         {
  8.         }
  9.  
  10.         void IHttpModule.Init(HttpApplication Application)
  11.         {
  12.             AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);
  13.             Application.Error += new EventHandler(this.context_Error);
  14.         }
  15.  
  16.         void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
  17.         {
  18.             HttpApplication app = (HttpApplication)sender;
  19.             app.Response.Write(app.Server.GetLastError());
  20.         }
  21.  
  22.         void context_Error(object sender, EventArgs e)
  23.         {
  24.             HttpApplication app = (HttpApplication)sender;
  25.             app.Response.Write(app.Server.GetLastError());
  26.         }
  27.  
  28.         #endregion
  29.     }
  30.  
The pipeline initializes fine. But the context_Error is never called.

call for help, thanks
Zoltan
May 11 '07 #1
2 1644
jhardman
3,406 Expert 2GB
This should be set in IIS.

Wow, you're thorough, though.

Jared
May 11 '07 #2
zottty
27
This should be set in IIS.

Wow, you're thorough, though.

Jared
I'll try! Thanks!
May 11 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Jeremy Fincher | last post by:
I've just converted my application to use the logging module for its logging needs (it's quite excellent, actually :)). One thing I still have to resolve, though: in many places in my application,...
12
by: Ritz, Bruno | last post by:
hi in java i found that when a method has a throws clause in the definition, callers must either handle the exceptions thrown by the method they are calling or "forward" the exception to the...
3
by: Ross | last post by:
Hi, I have a message box that displays the message "Unhandled exception in Cash32.exe: 0xC000005: access violation". Is there anyway to write an exception that handles this message. For...
6
by: Jesper Ordrup Christensen | last post by:
Say I've created a piece of code that involves both sql, io and some number conversions. Being a responsible developer I have tried to catch all of the exceptions - but how can I be sure? Is...
9
by: David B | last post by:
Why is it so difficult to report bugs to Microsoft? I have a documented bug and an small test example. I don't really see why I should have to pay to tell them about it... Anyway, the...
5
by: Jason MacKenzie | last post by:
I have a production critical windows forms application. I have try catch blocks everywhere to handle every eventuality. However occasionally, every couple of months, the application crashes. Its...
11
by: chopsnsauce | last post by:
Here's the example: Dim frm As New FORM1 Try frm.show Catch ex As Exception msgbox ex.message
16
by: john6630 | last post by:
Coming from the .Net world, I am used to the try...catch...finally approach to error handling. And PHP 5 now supports this approach. But I am not clear what happens to unhandled errors/exceptioins?...
5
by: Paul Rubin | last post by:
I think I've asked about this before, but is there a way to set up Python to handle uncaught exceptions with pdb? I know about setting sys.except_hook to something that calls pdb, but this is...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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.