Common Exception Handling and web. config Configuration Analysis in ASP. NET project development

Source: Internet
Author: User

In ASP. NET project development, application exception handling is mainly at the page and method layers. We will separate the descriptions:

◆ Page-level Exception Handling

In addition to writing the processing code in Global. asax, we can also write the code in Page_Error on the page:

 
 
  1. public void Page_Error(object sender, EventArgs e)  
  2.  
  3. {  
  4.  
  5.  //Insert same code that is in the Application_Error event.  
  6.  

If an error occurs on the page, the code above will be executed. We can copy all the Code previously written in the Application_Error event to the Page_Error processing method. However, in this case, the code in Application_Error will not run, because the exception is already handled in the previous section, that is, Page_Error.

◆ Method-level processing

I believe that everyone is very familiar with this, that is, the use of common try... catch... finally statement blocks. I will not go into details here.

In ASP. NET project development, how does one implement the web. config configuration?

◆ Web. config Configuration

The exception is usually configured in the web. config file. Node:

 
 
  1.   "RemoteOnly"    
  2.  
  3. defaultRedirect="ErrorPage.aspx">  
  4.  
  5.    "403"  redirect= "NoAccess.htm"  />  
  6.    
  7.   "404"  redirect= "FileNotFound.htm"  />  
  8.    
  9.  

You should be familiar with some attributes in the node.

In ASP. NET project development, we will introduce you to common exception handling and basic web. config configurations, and hope to help you.

  1. Application of ASP. NET trace in page execution
  2. Introduction to ASP. NET Request Object Attributes
  3. Analysis on adding watermarks to Images Using ASP. NET (VB)
  4. Introduction to ASP. NET page framework
  5. Analysis of Application Exception Handling in ASP. NET project development

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.