Sideway
output.to from Sideway





Draft for Information Only

Content

ASP.NET @ Webpage Directives
  @ Import
   Syntax
   Attributes
  Remarks
  @ Master
   Syntax
   Attributes
  Attribute Values
  Remarks
  @ MasterType
   Syntax
   Attributes
  Attribute Values
  Remarks
 @ OutputCache
   Syntax
   Attributes
  Remarks
  Source/Reference

ASP.NET @ Webpage Directives

The webpage directives for web form and user control are @ Assembly:, @ Control, @ Implements, @ Import, @ Master, @ MasterType, @ OutputCache, @ Page, @ PreviousPageType, @ Reference, and @ Register.

@ Import

The @ Import is used to explicitly imports a namespace into an ASP.NET application file (such as a Web page, a user control, a master page, or a Global.asax file), making all classes and interfaces of the imported namespace available to the file. The imported namespace can be part of the .NET Framework class library or a user-defined namespace.

Syntax

<%@ Import namespace="value" %>

Attributes

@ ImportKeywords of @ Import directive NameAttribute keyword used to specify namespace by name "value"The fully qualified name of the namespace to import. This can include any of the namespaces included in the .NET Framework or a custom namespace.

Remarks

  • The @ Import directive cannot have more than one namespace attribute. To import multiple namespaces, use multiple @ Import directives.
  • A set of namespaces can be automatically imported into .aspx pages. The imported namespaces are defined in the machine-level Web.config file, within the <namespaces> section of the <pages> element. The following namespaces are automatically imported into all pages:
    • System
    • System.Collections
    • System.Collections.Specialized
    • System.Configuration
    • System.Text
    • System.Text.RegularExpressions
    • System.Web
    • System.Web.Caching
    • System.Web.Profile
    • System.Web.Security
    • System.Web.SessionState
    • System.Web.UI
    • System.Web.UI.HtmlControls
    • System.Web.UI.WebControls
    • System.Web.UI.WebControls.WebParts

@ Master

The @ Master directive is used to define master page–specific (.master file) attributes that are used by the ASP.NET page parser and compiler.

Syntax

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

Attributes

@ MasterKeywords of @ Master directive attributeSpecified keywords from a list of attribute name used to specify attribute of @ Master attribute. "value"The specified value of the specified attribute of @ Master attribute.

Attribute Values

AutoEventWireupIndicates whether simple event handlers can be defined for specific life cycle stages using the syntax Page without any explicit hookup or event signature. true if event auto-wiring is enabled; otherwise, false. The default is true. ClassNameSpecifies the class name for the class that is automatically generated from the markup and compiled when the master page is processed. This value can be any valid class name and can include a namespace. CodeFileSpecifies the name of a separate file that contains a partial class with the event handlers and other master page–specific code. CompilationModeSpecifies whether to compile an ASP.NET master page at run time. Options are Always to always compile the page; Auto, if ASP.NET is to avoid compiling the page, if possible; and Never, to never compile the page or control. The default is Always. CompilerOptionsProvides a string containing compiler options to use to compile the page. In C# and Microsoft Visual Basic, this is a sequence of compiler command-line switches. DebugIndicates whether to compile the master page with debug symbols. true, to compile with debug symbols; otherwise, false. DescriptionProvides a text description of the master page. This value is ignored by the ASP.NET parser. EnableThemingIndicates whether the appearance of the master page and of controls on the master page can be modified, if a theme is applied. true if a theme can be applied; otherwise, false. The default is true. Setting the EnableTheming attribute is primarily useful when a page theme is defined in the Web.config file and applies to all pages, by default. EnableViewStateIndicates whether view state is maintained across page requests. true to maintain view state; otherwise, false. The default is true. ExplicitDetermines whether the page is compiled using the Visual Basic Option Explicit mode. true indicates that the Visual Basic explicit compile option is enabled and that all variables must be declared using a Dim, Private, Public, or ReDim statement; otherwise, false. The default is false. Note: The Explicit attribute is ignored by languages other than Visual Basic. The Explicit attribute is set to true in the Machine.config file. InheritsSpecifies a code-behind class for the page to inherit. This can be any class derived from the MasterPage class. LanguageSpecifies the language used when compiling all inline rendering (<% %> and <%= %>) and code declaration blocks within the page. Values can represent any language that is supported by the .NET Framework, including VB (Visual Basic), C#, and JScript. LinePragmasDetermines whether the runtime should generate pragmas in the generated code. MasterPageFileSpecifies the .master file that acts as a master page for a master page. The MasterPageFile attribute is used in a master page when defining a child master page in a nested master-page scenario. SrcSpecifies the source file name of the code-behind class to dynamically compile when the page is requested. You can choose to include programming logic for your page either in a code-behind class or in a Code Declaration Blocks in the .aspx file. StrictSpecifies whether to compile the page using the Visual Basic Option Strict mode. true if Option Strict is enabled; otherwise, false. The default is false. Note: The Strict attribute is ignored by languages other than Visual Basic. WarningLevelSpecifies the compiler warning level at which you want the compiler to abort compilation for the page. Possible values are from 0 through 4.

Remarks

  • @ Master directive can be used only in master pages.
  • Master pages are defined in files with the .master extension.
  • Only one @ Master directive can be included per .master file.

@ MasterType

The @ MasterType directive is used to provides a way to create a strongly typed reference to the ASP.NET master page when the master page is accessed from the Master property.

Syntax

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

Attributes

@ MasterTypeKeywords of @ MasterType directive attributeSpecified keywords from a list of attribute name used to specify attribute of @ MasterType attribute. "value"The specified value of the specified attribute of @ MasterType attribute.

Attribute Values

TypeNameSpecifies the type name for the master page. VirtualPathSpecifies the path to the file that generates the strong type.

Remarks

  • Use the @ MasterType directive to set the strong type for the master page, as accessed through the Master property.
  • if VirtualPath is not defined, the type must exist in one of the currently linked assemblies, such as App_Bin or App_Code.
  • If both attributes, TypeName and VirtualPath, are defined, the @ MasterType directive will fail.

@ OutputCache

The @ OutputCache directive is used to declaratively control the output caching policies of an ASP.NET page or a user control contained in a page.

Syntax

<%@ OutputCache Duration="#ofseconds"
   Location="Any | Client | Downstream | Server | None | ServerAndClient "
   Shared="True | False"
   VaryByControl="controlname"
   VaryByCustom="browser | customstring"
   VaryByHeader="headers"
   VaryByParam="parametername" 
   VaryByContentEncoding="encodings"
   CacheProfile="cache profile name | ''"
   NoStore="true | false"
   SqlDependency="database/table name pair | CommandNotification"
   ProviderName="Provider Name" 
%>

Attributes

@ OutputCacheKeywords of @ OutputCache directive " ⋯ "Optional values "Duration"The time, in seconds, that the page or user control is cached. Setting this attribute on a page or user control establishes an expiration policy for HTTP responses from the object and will automatically cache the page or user control output. Note: This attribute is required. If you do not include it, a parser error occurs. LocationOne of the OutputCacheLocation enumeration values. The default is Any. Note: This attribute is not supported for @ OutputCache directives included in user controls (.ascx files). CacheProfileThe name of the cache settings to associate with the page. This is an optional attribute and defaults to an empty string (""). Note This attribute is not supported for @ OutputCache directives included in user controls (.ascx files). When specified on a page, the value must match the names of one of the available entries in the outputCacheProfiles element under the outputCacheSettings section. If the name does not match a profile entry, an exception is thrown. NoStoreA Boolean value that determines whether to prevent secondary storage of sensitive information. Note This attribute is not supported for @ OutputCache directives included in user controls (.ascx files). Setting this attribute to true is equivalent to the following code executed during the request: Response.Cache.SetNoStore(); ProviderNameA string value that identifies the custom output-cache provider to used. Note This attribute is supported only in user controls (.ascx files). It not supported for @ OutputCache directives that are included in ASP.NET pages (.aspx files). SharedA Boolean value that determines whether user control output can be shared with multiple pages. The default is false. For more information, see the Remarks section. Note This attribute is not supported for @ OutputCache directives included in ASP.NET pages (.aspx files). SqlDependencyA string value that identifies a set of database and table name pairs that a page or control's output cache depends on. Note that the SqlCacheDependency class monitors the table in a database that the output cache depends on, so that when items in a table are updated, those items are removed from the cache when using table-based polling. When using notifications (in Microsoft SQL Server 2005) with the value CommandNotification, ultimately a SqlDependency class is used to register for query notifications with the SQL Server 2005 server. Note The CommandNotification value for the SqlDependency attribute is valid only on Web (.aspx) pages. User controls can only use table-based polling with the @ OutputCache directive. VaryByCustomAny text that represents custom output caching requirements. If this attribute is given a value of browser, the cache is varied by browser name and major version information. If a custom string is entered, you must override the GetVaryByCustomString method in your application's Global.asax file. VaryByHeaderA semicolon-separated list of HTTP headers used to vary the output cache. When this attribute is set to multiple headers, the output cache contains a different version of the requested document for each combination of specified headers. Note Setting the VaryByHeader attribute enables caching items in all HTTP version 1.1 caches, not just the ASP.NET cache. This attribute is not supported for @ OutputCache directives in user controls. VaryByParamA semicolon-separated list of strings used to vary the output cache. By default, these strings correspond to a query string value sent with GET method attributes, or a parameter sent using the POST method. When this attribute is set to multiple parameters, the output cache contains a different version of the requested document for each combination of specified parameters. Possible values include none, an asterisk (*), and any valid query string or POST parameter name. Caution noteCaution Either this attribute or the VaryByControl attribute is required when you use the @ OutputCache directive on ASP.NET pages and user controls. A parser error occurs if you fail to include it. If you do not want to specify a parameter to vary cached content, set the value to none. If you want to vary the output cache by all parameter values, set the attribute to an asterisk (*). VaryByControlA semicolon-separated list of strings used to vary a user control's output cache. These strings represent the ID property values of ASP.NET server controls declared in the user control. For more information, see Caching Portions of an ASP.NET Page. Note Either this attribute or the VaryByParam attribute is required when you use the @ OutputCache directive on ASP.NET pages and user controls. VaryByContentEncodingsA semicolon-separated list of strings that are used to vary the output cache. The VaryByContentEncodings attribute is used with the Accept-Encoding header to determine how cached responses are served for different content encodings. For more information about how to specify the Accept-Encoding header, see section 14.3 of the Hypertext Transfer Protocol -- HTTP/1.1 specification on the W3C Web site.

Remarks

  • Setting values for the page output cache is the same as manipulating the SetExpires and SetCacheability methods through the Cache property.
  • If a Web Forms page requires authorization to be viewed by a user, the output cache sets the Cache-Control HTTP header to private.
  • If you set the Shared attribute to true, cached user control output can be accessed by multiple Web Forms pages. If you do not set it to true, the default behavior is to cache one version of user control output for each page that contains that user control. You can potentially save a significant amount of memory by enabling the Shared attribute.

Source/Reference

  • https://docs.microsoft.com/en-us/previous-versions/t8syafc7(v=vs.140)
  • https://docs.microsoft.com/en-us/previous-versions/dotnet/netframework-4.0/eb44kack(v=vs.100)
  • https://docs.microsoft.com/en-us/previous-versions/dotnet/netframework-4.0/ms228176(v=vs.100)
  • https://docs.microsoft.com/en-us/previous-versions/dotnet/netframework-4.0/ms228274(v=vs.100)
  • https://docs.microsoft.com/en-us/previous-versions/dotnet/netframework-4.0/hdxfb6cy(v=vs.100)

©sideway
close

References

  1. Active Server Pages, http://msdn.microsoft.com/en-us/library/aa286483.aspx, updated 20Dec2012
  2. ASP Overview, http://msdn.microsoft.com/en-us/library/ms524929%28v=vs.90%29.aspx, updated 21Dec2012
  3. ASP Best Practices, http://technet.microsoft.com/en-us/library/cc939157.aspx, updated 15Apr2013
  4. ASP Built-in Objects, http://msdn.microsoft.com/en-us/library/ie/ms524716(v=vs.90).aspx, updated 20Dec2012
  5. Response Object, http://msdn.microsoft.com/en-us/library/ms525405(v=vs.90).aspx, updated 20Dec2012
  6. Request Object, http://msdn.microsoft.com/en-us/library/ms524948(v=vs.90).aspx, updated 20Dec2012
  7. Server Object (IIS), http://msdn.microsoft.com/en-us/library/ms525541(v=vs.90).aspx, updated 20Dec2012
  8. Application Object (IIS), http://msdn.microsoft.com/en-us/library/ms525360(v=vs.90).aspx, updated 20Dec2012
  9. Session Object (IIS), http://msdn.microsoft.com/en-us/library/ms524319(8v=vs.90).aspx, updated 20Dec2012
  10. ASPError Object, http://msdn.microsoft.com/en-us/library/ms524942(v=vs.90).aspx, updated 20Dec2012
  11. ObjectContext Object (IIS), http://msdn.microsoft.com/en-us/library/ms525667(v=vs.90).aspx, updated 20Dec2012
  12. Debugging Global.asa Files, http://msdn.microsoft.com/en-us/library/aa291249(v=vs.71).aspx, updated 15Apr2013
  13. How to: Debug Global.asa files, http://msdn.microsoft.com/en-us/library/ms241868(v=vs.80).aspx, updated 15Apr2013
  14. Calling COM Components from ASP Pages, http://msdn.microsoft.com/en-us/library/ms524620(v=VS.90).aspx, updated 15Apr2013
  15. IIS ASP Scripting Reference, http://msdn.microsoft.com/en-us/library/ms524664(v=vs.90).aspx, updated 15Apr2013
  16. ASP Keywords, http://msdn.microsoft.com/en-us/library/ms524672(v=vs.90).aspx, updated 15Apr2013
  17. Creating Simple ASP Pages, http://msdn.microsoft.com/en-us/library/ms524741(v=vs.90).aspx, updated 15Apr2013
  18. Including Files in ASP Applications, http://msdn.microsoft.com/en-us/library/ms524876(v=vs.90).aspx, updated 15Apr2013
  19. ASP Overview, http://msdn.microsoft.com/en-us/library/ms524929(v=vs.90).aspx, updated 15Apr2013
  20. FileSystemObject Object, http://msdn.microsoft.com/en-us/library/z9ty6h50(v=vs.84).aspx, updated 14Mayr2013
  21. http://msdn.microsoft.com/en-us/library/windows/desktop/ms675944(v=vs.85).aspx, ADO Object Model, updated 15Apr2013
  22. ADO Fundamentals, http://msdn.microsoft.com/en-us/library/windows/desktop/ms680928(v=vs.85).aspx, updated 14Mayr2013
close

ID: 190600029 Last Updated: 2019/6/29 Revision: Ref:

IMAGE

Home (5)

Business

Management

HBR (3)

Information

Recreation

Hobbies (7)

Culture

Chinese (1097)

English (336)

Reference (66)

Computer

Hardware (149)

Software

Application (187)

Digitization (24)

Numeric (19)

Programming

Web (618)new

CSS (SC)

ASP.NET (SC)

HTML

Knowledge Base

Common Color (SC)

Html Entity (Unicode) (SC)

Html 401 Special (SC)

OS (388)new

MS Windows

Windows10 (SC)

.NET Framework (SC)

DeskTop (7)

Knowledge

Mathematics

Formulas (8)

Number Theory (206)

Algebra (20)

Trigonometry (18)

Geometry (18)

Calculus (67)

Complex Analysis (21)

Engineering

Tables (8)

Mechanical

Mechanics (1)

Rigid Bodies

Statics (92)

Dynamics (37)

Fluid (5)

Fluid Kinematics (5)

Control

Process Control (1)

Acoustics (19)

FiniteElement (2)

Biology (1)

Geography (1)


Copyright © 2000-2019 Sideway . All rights reserved Disclaimers last modified on 10 Feb 2019