Error log wrapper policy for ASP. NET production environment and development environment

Source: Internet
Author: User
Tags custom name

For the output of the error log, we use the two flag bits of Web. config:

<!--Global Wrapper exception handling page, only in Pageerror and Application_Error do clear error action can not jump -<!--set to OFF when debugging, production environment This entry must be on -<customErrorsMode= "Off"defaultredirect= "~/errorpage/404/index.html"><ErrorStatusCode= "404"redirect= "~/errorpage/404/index.html"/></customErrors>
<!-- set to True when debugging, production environment This entry must be false  - <  Debug= "true"  targetframework= "4.0">

Where I rewrite three events: the base class of the background page overrides the "Pageerror", the base class of the foreground MVC overrides the "Controllerexception (this event is a custom name, a reference to MVC's error rewrite)," global "application_ Error ", and then follow these guidelines:

1, "Application_Error":

① for foreground error prompt policy, non-debug mode, open the default error jump page, all only the stack to the database, do not wrap the jump, use the default error jump page

② in non-debug mode, the stack is displayed only when localhost accesses the site

③ non-debug mode, no default error jump is turned on, direct output of package exception information

2, "controllerexception":

①MVC foreground error prompt policy, non-debug mode, open the default error jump page, all only record stacks to the database, do not wrap the jump, use the default error jump page

② in non-debug mode, the stack is displayed only when localhost accesses the site

③ non-debug mode, no default error jump is turned on, direct output of package exception information

3, "Pageerror":

① background error Prompt policy, non-debug mode, all record stack to database, and wrapper jump

② in non-debug mode, the stack is displayed only when localhost accesses the site

Attachment:

Error page Template: Https://github.com/easonjim/3_web_example/tree/master/htmlpage

Error log wrapper policy for ASP. NET production environment and development environment

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.