Specify the base class of the page in Web. config.

Source: Internet
Author: User

Setting a unified page base class for a website is definitely a good habit. You can complete many unified read/write processing and behavior encapsulation in the base class, such as implementing anti-Refresh mechanisms and IP address shielding.

In the Web. config file, you can specify the page base class by specifying the pagebasetype attribute of the pages node in system. Web:

However, the concept of this attribute is vague. I once thought that this attribute will change the template of the newly created page so that they can directly inherit the base class you set, but this is not the case.

First, this attribute will make allCodeThe independent ASPX page of is automatically inherited from this base class, such as the page declared as follows:

In addition, this attribute also reports errors to all pages that contain background code but do not inherit from this base class, such as the page declared as follows:

If the background code is the default inheritance code:

The following error message is displayed during compilation:

Modify the code to inherit from the previously set base class:

Compilation will pass.

I am using Visual Studio 2008 SP1 and. NET Framework 3.5 SP1. The processing methods of previous versions may be different.

Download thisArticlePdf version: http://www.box.net/shared/um31uo0lhs

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.