Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 139801
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T07:30:01+00:00 2026-05-11T07:30:01+00:00

I’ve been given the thrilling task of re-writing our exception handling system. Whilst I

  • 0

I’ve been given the thrilling task of re-writing our exception handling system. Whilst I will state that handling exceptions from an application-wide point of view isn’t something we want, typically it’s unavoidable when our team are understaffed for the sheer amount of work we need to push out the door, so please, no flaming the globalised solution to exception handling here 🙂

I’ve had a good hunt to see what common solutions exist. At the moment we use Global.asax with the Application_Error event to do Server.GetLastError() which is placed in Session state then a redirect is called to another page where the session data is then retrieved and output in a human readable format. The redirect also calls a sproc which will carefully audit the error information which is a) e-mailed to the developers and b) viewed from a web page only viewable by developers.

The new way I’ve seen of doing things is using the IHttpModule interface using a class in App_Code to do something along these lines (this is my quick implementation)

Imports Microsoft.VisualBasic  Public Class ErrorModule : Implements IHttpModule    Public Sub Dispose() Implements System.Web.IHttpModule.Dispose     ' Not used   End Sub    Public Sub Init(ByVal context As System.Web.HttpApplication) Implements System.Web.IHttpModule.Init     AddHandler context.Error, AddressOf context_Error   End Sub    Public Sub context_Error(ByVal sender As Object, ByVal e As EventArgs)     Dim ex As Exception = HttpContext.Current.Server.GetLastError      ' do something with the error     ' call the stored procedure     ' redirect the user to the error page      HttpContext.Current.Server.ClearError()     HttpContext.Current.Response.Redirect('index.htm')    End Sub End Class 

My question is, what is the benefit of this solution over using Global.asax events? Additionally, what is the best way to hand the data to an error page?

EDIT: The code above does work by the way 😉

EDIT: Also, how does the HttpModule work behind the scenes? Does it just register the Error event to that particular function on application start?

UPDATE:

Upon much further investigation it seems grabbing session data is really, really messy when it comes to using IHttpModule interface. I don’t think MS have matured HttpModule enough for it to be used in our particular scenario – until there are events specific to session data it’s too dangerous for us to use.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-11T07:30:02+00:00Added an answer on May 11, 2026 at 7:30 am

    Using a module has the advantage of being easily removable, all you need to do to disable it is to remove it from <httpModules> in your config.

    As far as your data goes, try going with Server.Transfer or Server.RewritePath – that will keep all the current data (including the last server error).

    If for some reason it clears the last error, you can save the error to HttpContext.Items before the transfer/rewrite and then retrieve it afterwards.

    Edit: In response to your edit, an IHttpModule attaches to any appropriate events in it’s IHttpModule.Init implementation.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 58k
  • Answers 58k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • added an answer My team uses LDAP as a standard way of authentication.… May 11, 2026 at 8:50 am
  • added an answer How about: conn = MySQLdb.connect(host, user, password, database) cursor =… May 11, 2026 at 8:50 am
  • added an answer You can create a self-extracting installer with tools such as… May 11, 2026 at 8:50 am

Top Members

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

Related Questions

No related questions found

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.