Поделиться через


@ Application - Global.asax

Defines application-specific attributes used by the ASP.NET application compiler, and appears only in application (.asax) files.

<%@ Application attribute="value" [attribute=value … ]%>

Attributes

  • CodeBehind
    Specifies the name of a source code file that contains a class associated with the application class. This is ignored by the ASP.NET parser; it is used only at design time by integrated development environment (IDE) tools such as Microsoft Visual Studio 2005.

    Note

    This attribute is included for compatibility with previous versions of ASP.NET, to implement the code-behind feature. In ASP.NET version 2.0, you should instead use the CodeFile attribute to specify the name of the source file, along with the Inherits attribute to specify the fully qualified name of the class.

  • CompilerOptions
    A string containing compiler options used to compile the 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.
  • Description
    A text description of the application class. This value is ignored by the ASP.NET parser.
  • Inherits
    Defines a code-behind class for the application class to inherit. This can be any class derived from the HttpApplication class. Used with the CodeFile attribute, which contains the path to the source file for the code-behind class. For more information about code-behind classes, see ASP.NET Web Page Code Model.
  • Language
    Specifies the language used when compiling all inline rendering (<% %> and <%= %>) and code declaration blocks within the application file. Values can represent any .NET Framework-supported language, including Visual Basic, C#, or JScript. Only one language can be used and specified per application file.

Remarks

The Description and Inherits attributes can be declared together in the same @ Application directive, as shown in the Example section.

If you want to use code separation for the application class, you must use the Inherits attribute to specify the name of a code-behind class from which the application class will inherit. Optionally, if you are using an IDE (such as Microsoft Visual Studio 2005) that provides tools for working with code separation source files in code projects, you can add the CodeFile attribute to specify the code-behind source file name.

Example

The following code example instructs the ASP.NET application compiler to dynamically compile a new application class that extends the My401kApp.Object class.

<%@ Application Inherits="My401kApp.Object" Description="Our 401k app" %>

See Also

Reference

Application Directives

Other Resources

Global.asax Syntax