Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Logging all unhandled ASP.NET C# exceptions

Posted on 2008-06-18
2
Medium Priority
?
798 Views
Last Modified: 2011-10-03
This is probably quite easy; does anyone know how I can log all unhandled exceptions on my ASP.NET application to a database? Ie, for any unhandled exception, call LogException(Exception e) and then divert user to a page which says "The website has encountered an error - the administrator has been notified".

ASP.NET, C#
0
Comment
Question by:jimstar
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 16

Accepted Solution

by:
ororiole earned 2000 total points
ID: 21818575
Yes indeed. The framework has just such a feature. To your solution right click and add a new item. Add a global.asax file. (I think the dialog calls it a global class file or something). In there you will see an
Applicaiton_Error event handler. Modify it like so, assumeing you have a LogException function:
        protected void Application_Error(object sender, EventArgs e)
        {
            LogException(Server.GetLastError());
            Server.ClearError();
            Server.Transfer("Default2.aspx");
 
        }

Open in new window

0
 
LVL 4

Author Closing Comment

by:jimstar
ID: 31468643
Fantastic, thanks!
0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A quick way to get a menu to work on our website, is using the Menu control and assign it to a web.sitemap using SiteMapDataSource. Example of web.sitemap file: (CODE) Sample code to add to the page menu: (CODE) Running the application, we wi…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…

715 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question