Error Handling In Asp.net 3.5
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow the company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up Implementing exception handling in ASP.NET 3.5 up vote 4 down vote favorite 1 I would like to implement exception handling on a ASP.NET application. How do you suggest I implement it? Some requirements are: User should see a friendly page when an exception occurs Admin should get an email with exception details I understand there are several ways of implementing exceptions (ex: Log messages in the event viewer) What's the recommended approach? asp.net exception-handling share|improve this question asked Jan 25 '10 at 0:25 Nick 3,3511358115 add a comment| 3 Answers 3 active oldest votes up vote 2 down vote accepted The recommended approach really depends on what you need to do with the error information. For simple apps, just setting up the web.config file to redirect to a friendly error page might be enough. It's usually a good idea to record unhandled error information to a database, file, windows application log or web service by handling them with the Global.asax Application_Error event. You can also use the web.config to get your friendly page with that. Generally I wouldn't recommend using the windows error logs as they tend to be a bit obtuse, but there's nothing wrong with it. For very detailed operational information, including warnings and info messages, tools like log4net are widely used. Usually you would go this route for products or enterprise level applications where your support teams need as much information as possible to diagnose the errors. MSDN has a walkthrough of some of the basic error handling setups and what you can do with them. share|improve this answer answered Jan 25 '10 at 0:54 womp 88.5k18186245 add a comment| Did you find this question interesting? Try our newsletter Sign up for our newsletter and get our top new questions delivered to your inbox (see an example). Subscribed! Success! Please click the link in th
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow the company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up Design Pattern for error handling in ASP.NET 3.5 site up vote 0 down vote favorite I am relatively new to ASP.NET programming, and web programming in general. We have a site we recently ported from .NET 1.1 to 3.5. Currently we http://stackoverflow.com/questions/2129541/implementing-exception-handling-in-asp-net-3-5 have two methods of error handling: either catching the error during data load on a page and displaying the formatted error in a label on the page, or redirecting to a generic error page. Both of these are somewhat annoying, as right now I'm trying to redesign how our errors are displayed. We are soon moving to Master pages, and I'm wondering if there is a way to "build in" an error handling control. What I mean by this is using a ASP.NET user http://stackoverflow.com/questions/2676607/design-pattern-for-error-handling-in-asp-net-3-5-site control I've designed that simply gets passed the error string returned from the server. If an error occurs, the page would not display the content, and instead display the error control. This provides us with the ability to retain the current banner/navigation during an error (which we don't get with the generic error page), as well as keeping me from having to add the control to every aspx page we have (which I have to do with using the label-per-page system). Does something like this make sense? Ultimately I just want to have the error control added to a single page, and all other pages have access to it directly. Is this something Master pages help with? Thanks! asp.net .net-3.5 error-handling master-pages share|improve this question asked Apr 20 '10 at 15:56 Kevin 68841131 add a comment| 1 Answer 1 active oldest votes up vote 2 down vote accepted User the application_error event in the global.asax to catch all your unhandled errors - you can log them here. You shouldn't be outputting error messages to the client like this. Use the CustomErrors section in the web.config to define a custom error page for your users to get. You could also look at using something like ELMAH for easy loggin. share|improve this answer answered Apr 20 '10 at 15:59 Paddy 23k95691 Thanks for the link to ELMAH, we may use something like this. The real issue we have is not with unhandled exceptions, its more with our server returnin
resources Windows Server 2012 resources Programs MSDN subscriptions Overview Benefits Administrators Students Microsoft Imagine Microsoft Student Partners https://msdn.microsoft.com/en-us/library/ms229005(v=vs.100).aspx ISV Startups TechRewards Events Community Magazine Forums Blogs Channel 9 Documentation APIs and reference Dev centers Retired content Samples We’re sorry. The content you requested has been removed. You’ll be auto redirected in 1 second. General Reference for the .NET Framework Design Guidelines for Developing Class Libraries error handling Design Guidelines for Exceptions Design Guidelines for Exceptions Exception Handling Exception Handling Exception Handling Exception Throwing Exception Handling Catching and Throwing Standard Exception Types Designing Custom Exceptions Exceptions and Performance TOC Collapse the table of content Expand the table of content This documentation is archived and is not error handling in being maintained. This documentation is archived and is not being maintained. This documentation is archived and is not being maintained. Exception Handling Visual Studio 2010 Other Versions Visual Studio 2008 .NET Framework 3.5 .NET Framework 3.0 .NET Framework 2.0 The following guidelines help ensure that your library handles exceptions appropriately.Do not handle errors by catching non-specific exceptions, such as System.Exception, System.SystemException, and so on, in framework code.You can catch exceptions when the purpose of catching the exception is to re-throw or transfer the exception to a different thread. The following code example demonstrates incorrect exception handling. C#C++VB Copy public class BadExceptionHandlingExample1 { public void DoWork() { // Do some work that might throw exceptions. } public void MethodWithBadHandler() { try { DoWork(); } catch (Exception e) { // Handle the exception and // continue executing. } } } Avoid handling error