asp.net error handling encapsulation

Source: Internet
Author: User
Tags error handling

/*----------------------------------------------------------------

* Copyright (C)

* All rights reserved.

*

* FileName: ErrorManager.cs

* Function Description: asp.net in the common error repair, with this class matching need to add an error message display page, such as Error.aspx

*

* Use instructions: 1. Start the timer (timed emptying error message) in Application_Start (): ErrorManager.Instance.Start (),

* The default 12-hour run time, or with ErrorManager.Instance.SetTimerInterval () set.

* 2. In Application_Error (), when an error occurs, save the error message and go to error.aspx to display the error

* String key = ErrorManager.Instance.AddError ();

* Response.Redirect ("error.aspx?key=" + key);

* 3. In Error.aspx, the key is passed through the URL to obtain and display an error message:

* String err = ErrorManager.Instance.GetError (key)

* The first 19 characters in Err are the time when the error occurred, followed by the error message.

* 4. In order to catch a session timeout error, instead of returning Session[key] is a null error message, this class adds GetSession ()

* and the Setsession function to unify the management session, in the future ASPX cannot read the session directly, but must read through this class.

*

*

* Create identity:

*

* Modify the identity:

* Modify Description:

*

* Modify the identity:

* Modify Description:

*----------------------------------------------------------------*/

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.