@ Page command reference

Source: Internet
Author: User
Tags sql server injection

Defines the page-specific (. aspx file) attributes used by ASP. NET page analyzer and compiler.

<% @ Page attribute = "value" [attribute = "value"...] %>
 

Attribute
Async
Make the page an asynchronous Processing Program (that is, the page uses the IHttpAsyncHandler implementation to process the request ).

The default value is false.

AsyncTimeOut
Defines the timeout interval (in seconds) used to process asynchronous tasks ). The default value is 45 seconds.

The value must be an integer.

AspCompat
When this parameter is set to true, pages can be executed on a single-threaded unit (STA) thread. This allows pages to call the STA components, such as those developed with Microsoft Visual Basic 6.0. Set this property to true and allow page calls to COM + 1.0 components. This component requires access to the embedded objects of the unmanaged Active Server Pages (ASP. You can access them through the ObjectContext object or the OnStartPage method. The default value is false.

Note:
Setting this attribute to true may result in poor page performance. For more information, see the "Remarks" section.
 

AutoEventWireup
Indicates whether the page events are automatically bound. True if event auto binding is enabled; otherwise, false. The default value is true. For more information, see ASP. NET Web server control event model.

Buffer
Determine whether HTTP Response buffering is enabled. True if page buffering is enabled; otherwise, false.

The default value is true.

ClassName
A string that specifies the Class Name of the page that will be automatically dynamically compiled upon request page. This value can be any valid class name and can include the complete namespace (fully qualified class name) of the class ). If this attribute value is not specified, the class name on the compiled page is based on the page file name.

For other pages, you can use the @ Reference command to Reference the class name assigned to the first page.

ClientTarget
Indicates the target user proxy (usually a Web browser, such as Microsoft Internet Explorer) for which the ASP. NET Server Control should present content ). This value can be any valid alias defined in the <clientTarget> section of the application configuration file.

CodeBehind
Specifies the name of the compiled file that contains the class associated with the page. This attribute cannot be used at runtime.

Note:
This attribute is provided to be compatible with previous versions of ASP. NET for code hiding. In ASP. NET 2.0, you should use the CodeFile attribute to specify the name of the source file, and use the Inherits attribute to specify the fully qualified name of the class.
 

CodeFile
Specifies the path of the code hidden file pointing to the page reference. This property can be used together with the Inherits property to associate the hidden source file of code with the webpage. This attribute is only valid for compiled pages.

CodeFileBaseClass
Specifies the path of the base class of the page and its associated code hidden class. This attribute is optional, but if you use this attribute, you must use the CodeFile attribute at the same time. If you want to implement the following sharing scheme, you can use this attribute: In this sharing scheme, you define common fields in the base class (you can selectively define associated events) to reference the control declared on the web page. Out of ASP. NET code generation model. If you do not use this attribute when defining a field in the base class, the compilation will be on the webpage (in a separate branch class stub) the declared control generates a new member definition, and the scheme you want will not take effect. However, if you use the CodeFileBaseClass attribute to associate the base class with the page and your branch class (its name is assigned to the Inherits attribute and its source file is referenced by the CodeFile attribute) is inherited from the base class, the fields in the base class will be able to reference the controls on the page after the code is generated.

CodePage
Indicates the value of the encoding scheme used for the response. This value is an integer used as the encoding scheme ID. For a list of possible CodePage IDs, see Encoding class.

CompilationMode
Set whether to use a string that specifies one of multiple enumeration options to compile the page. The default value is Always. Therefore, the. aspx page is compiled by default. For more information, see CompilationMode enumeration.

CompilerOptions
A string that contains compiler options for the compilation page. In C # and Visual Basic, This is a sequence of compiler command line switches. For more information about compiler options, see C # compiler options or Visual Basic compiler.

ContentType
Define the HTTP content type of the response as the standard MIME type. Supports any valid HTTP Content string. For a list of possible values, search for MIME in the MSDN Library.

Culture
Regional settings on the page. The value of this attribute must be a valid Regional ID. Note that LCID and Culture attributes are mutually exclusive. If one attribute is used, another attribute cannot be used on the same page. For more information about possible regional values, see the CultureInfo class.

Debug
Indicates whether the page should be compiled using debugging symbols. True if the page should be compiled with a debug symbol; otherwise false. Because this setting affects performance, this attribute should be set to true only during development.

Description
Provides text descriptions for this page. ASP. NET analyzer ignores this value.

EnableEventValidation
Enable event verification in the resend solution. True if the event is verified; otherwise, false. The default value is true.

EnableSessionState
Define the session status requirements for the page. If the session status is enabled, the value is true. If the session status can be read but cannot be changed, the value is ReadOnly; otherwise, the value is false. The default value is true. These values are case insensitive. For more information, see ASP. NET session status.

EnableTheming
Indicates whether to use a topic on the page. If the topic is used, the value is true; otherwise, the value is false. The default value is true.

EnableViewState
Indicates whether to maintain the view status between page requests. True if you want to maintain the view status; otherwise, false. The default value is true.

EnableViewStateMac
Indicates whether ASP. NET should run the computer authentication check (MAC) on The View status of the page when the page is sent back from the client ). If you want to run MAC check on The View status, the value is true; otherwise, the value is false. The default value is false.

Note:
View state MAC is the encrypted version of the Hidden variable. When a page is sent to a browser, the view State of the page is permanently kept in the variable. When you set this attribute to true, the encrypted view status is checked to verify that it has not been tampered with on the client. Note: setting this attribute to true affects performance because the variable values must be encrypted and decrypted during each round-trip of the page.
 

ErrorPage
Defines the target URL to be redirected when an unhandled page exception occurs.

Explicit
Determine whether to use Visual Basic Option Explicit mode to compile the page. If Visual Basic explicit compilation is enabled and all variables must be declared using Dim, Private, Public, or ReDim statements, true is used; otherwise, false is used. The default value is false.

Note:
This attribute is ignored in all languages except Visual Basic. In addition, this option is set to true in the Machine. config configuration file. For more information, see computer configuration files.
 

Inherits
Defines the code hidden class for page inheritance. It can be any class derived from the Page class. It is used together with the CodeFile attribute (including the path of the source file pointing to the code hidden class. For more information about the code hiding class, see ASP. NET webpage code model.

Language
Specifies the language used for compiling all inline rendering (<%> and <% = %>) and Code declaration blocks on the page. The value can represent any language supported by. NET Framework, including Visual Basic, C #, or JScript. Each page can only use and specify one language.

LCID
Defines the region settings identifier of the Web form page.

Note:
The region settings identifier is a 32-bit value that uniquely defines a region. ASP. NET uses the default region settings of Web servers unless you specify different region settings for the Web forms page. Note that LCID and Culture attributes are mutually exclusive. If one attribute is used, another attribute cannot be used on the same page. For more information about region settings, search the MSDN Library.
 

LinePragmas
Determine whether the Runtime Library should generate a line of mixed attention in the source code. These are compiler options, which are usually used by debugging tools to mark specific locations in the source file. True if a line notice should be generated; otherwise, false.

MaintainScrollPositionOnPostback
Indicates whether to return the user to the same location in the browser on the client after sending the request. True if the user should be returned to the same position; otherwise false. The default value is false.

Note:
Developers can define this attribute for all pages by setting the maintainScrollPostitionOnPostback attribute on the <pages> element of the Web. config file (note that this attribute is case sensitive in the configuration file.
 

MasterPageFile
Set the path of the master page or nested master page on the Content Page. Supports relative and absolute paths.

ResponseEncoding
Indicates the name of the encoding scheme used to include the HTTP Response of the page content. The value assigned to this attribute is a valid encoding name. For a list of possible Encoding names, see Encoding class. You can also call the GetEncodings method to obtain a list of possible encoding names and IDs.

SmartNavigation
Indicates whether the page supports smart navigation for Internet Explorer 5.5 or later. True if intelligent navigation is enabled; otherwise, false. The default value is false.

You can also set the SmartNavigation Attribute (Property) of the Page in code, but you should usually use the Attribute together with the @ Page command to set the Property ). For more information about how this function improves the user's navigation experience on the web page, see the SmartNavigation attribute.

Src
Specifies the path of the source file containing the Code that links to the page. In the source file of the link, you can choose to include the page programming logic in the class or the Code declaration block.

You can use the Src property to link the generated provider to the page. For more information, see BuildProvider class. In addition, in ASP. NET versions earlier than 2.0, the Src attribute is another method to link a hidden code file to a page. In ASP. NET 2.0, the preferred way to link a hidden source file to a page is to use the Inherits attribute to specify the class and use the CodeFile attribute to specify the path of the source file of the class.

Strict
Indicates that pages should be compiled in Visual Basic OptionStrict mode. If Option Strict is enabled, true is used; otherwise, false is used. The default value is false.

Note:
This attribute is ignored in all languages except Visual Basic.
 

StyleSheetTheme
The identifier of a valid topic used on the page. If the StyleSheetTheme attribute is set, a separate control can override the style settings contained in the topic. In this way, the topic provides the overall appearance of the site, and you can use the settings contained in the StyleSheetTheme attribute to customize the page and specific settings of each control.

TargetSchema
The name of the solution used to verify the page content. This attribute is descriptive and does not actually perform verification. analyzer ignores this attribute.

Theme
The identifier of a valid topic used on the page. If the StyleSheetTheme attribute is not used when you set the Theme attribute, the independent style settings on the control will be overwritten, allowing you to create a unified and consistent page appearance.

Title
Specifies the title of the page displayed in the HTML <title> tag of the response. You can also use the title as the page attribute by programming. For more information, see the Title attribute.

Trace
Indicates whether to enable tracking. True if tracing is enabled; otherwise, false. The default value is false. For more information, see ASP. NET tracking.

TraceMode
Indicates how to display trace messages for pages when tracing is enabled. The possible values are SortByTime and SortByCategory. When tracing is enabled, the default value is SortByTime. For more information about tracing, see ASP. NET tracing.

Transaction
Indicates whether transactions are supported on the page. Possible values include Disabled, NotSupported, Supported, Required, and RequiresNew. The default value is Disabled.

UICulture
Specifies the page User Interface (UI) culture settings. Supports any valid UI culture values.

ValidateRequest
Indicates whether request verification is required. If true, request verification checks all input data based on the hard-coded list of potentially dangerous values. If a match occurs, the HttpRequestValidationException is thrown. The default value is true.

This feature is enabled in the computer configuration file (Machine. config. You can disable this function by setting this attribute to false in the application configuration file (Web. config) or on the page.

Note:
This feature helps reduce the risk of cross-site scripting attacks on simple pages or ASP. NET applications. If the application cannot correctly verify user input, it may be attacked by input in multiple formats, including cross-site scripting and Microsoft SQL Server injection attacks. All forms of input in the application should be carefully evaluated, and they must be correctly verified and encoded, or make sure that the application has exited before processing data or sending the information back to the client. There is no other way to do this.
 

ViewStateEncryptionMode
Use three possible enumerated values to determine how to encrypt the view status: Auto, Always, or Never. The default value is Auto, indicating that if a single control request is encrypted, the view State is encrypted. For more information, see ViewStateEncryptionMode enumeration.

WarningLevel
Indicates the level of warning that you want the compiler to consider as an error (thus suspending page compilation. Possible warning levels are 0 to 4. For more information, see WarningLevel attributes.

Remarks
This command can only be used on Web forms pages. Each. aspx file can contain only one @ Page command. In addition, each @ Page command can only define one Language attribute, because each Page can only use one Language. Most attributes provide the most common default values in the source code or configuration file. Therefore, you do not need to add many attributes to the command. In general, you should add the minimum property set required to specify the features that the page has. If you want to apply a public attribute to all pages (for example, you want to enable tracing on all pages), consider. the corresponding functions are enabled in the config file, instead of adding Trace properties to each individual page.

Note:
The @ Page command has a large number of other commands applied to the entire source file (for example, in the Web user control. the @ Control Command Used in the ascx file and. the attribute shared by the @ master command in the Master file.
 

To define multiple attributes of the @ Page command, use a space to separate each attribute/value pair. Do not add spaces on both sides of the equal sign (=) that connects a property to its value. For examples, see the "example" section in this topic.

Smart navigation is a feature of ASP. NET. Both Internet Explorer 5.5 and later versions support this feature. It makes it possible to retain the scroll position and element focus between navigation while refreshing the page. In this way, only one page is stored in the browser history, and there is no longer a common problem of flickering caused by PAGE refreshing. Intelligent Navigation has the best effect in ASP. NET pages, because ASP. NET pages require frequent sending back, but the visual content does not change significantly when returned. Consider this carefully when deciding whether to set this attribute to true.

When the AspCompat attribute of the page is set to true, if the COM component is created using the constructor before the scheduled request, the request runs on the multi-threaded unit (MTA) thread. This will cause a significant reduction in the Web server performance. To avoid this problem, create a COM component in only one Page event (such as Page_Load and Page_Init) or one Page method. Make sure that you do not create objects when creating pages.

The following code example demonstrates a recommended method for creating a COM object instance on the page when AspCompat is enabled.

C #
<% @ Page AspCompat = "true" language = "C #" %>
<Script runat = "server">

MyComObject comObj;

Public void Page_Load (){
// Use comObj here when the code is running on the STA thread pool.
ComObj = New MyComObject ();
// Do something with the combObj object.
}
 

Visual Basic
<% @ Page AspCompat = "true" language = "VB" %>
<Script runat = "server">

Dim comObj As MyComObject

Public Sub Page_Load ()
'Use comObj here when the code is running on the STA thread pool.
ComObj = New MyComObject ()
'Do something with the combObj object.
End Sub
</Script>
 

Note:
Adding the @ Master command to the Master page does not allow you to use the same command Declaration on pages that depend on the Master page. Use the <pages> element to define page commands globally.
 

Example
The following code example instructs the ASP. NET page compiler to use Visual Basic as the server-side code language of the page and set the default http mime ContentType attribute transmitted to the client to "text/xml ".


<% @ Page Language = "VB" ContentType = "text/xml" %>
 

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.