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