Online Book Reader

Home Category

Programming Microsoft ASP.NET 4 - Dino Esposito [94]

By Root 5427 0
memory are automatically killed and restarted by IIS. In IIS 7, you can even configure a periodic recycle to ensure that your application is always lean, mean, and in good shape.

Furthermore, the hosting environment (IIS or ASP.NET, depending on the configuration) implements a good deal of checks and automatically restarts an application if any the following scenarios occur:

The maximum limit of dynamic page compilations is reached. This limit is configurable through the web.config file.

The physical path of the Web application has changed, or any directory under the Web application folder is renamed.

Changes occurred in global.asax, machine.config, or web.config in the application root, or in the Bin directory or any of its subdirectories.

Changes occurred in the code-access security policy file, if one exists.

Too many files are changed in one of the content directories. (Typically, this happens if files are generated on the fly when requested.)

You modified some of the properties for the application pool hosting the Web application.

In addition to all this, in ASP.NET an application can be restarted programmatically by calling HttpRuntime.UnloadAppDomain.

The Processing Directives of a Page


Processing directives configure the run-time environment that will execute the page. In ASP.NET, directives can be located anywhere in the page, although it’s a good and common practice to place them at the beginning of the file. In addition, the name of a directive is case insensitive and the values of directive attributes don’t need to be quoted. The most important and most frequently used directive in ASP.NET is @Page. The complete list of ASP.NET directives is shown in Table 5-3.

Table 5-3. Directives Supported by ASP.NET Pages

Directive

Description

@ Assembly

Links an assembly to the current page or user control.

@ Control

Defines control-specific attributes that guide the behavior of the control compiler.

@ Implements

Indicates that the page, or the user control, implements a specified .NET Framework interface.

@ Import

Indicates a namespace to import into a page or user control.

@ Master

Identifies an ASP.NET master page. (See Chapter 8.)

@ MasterType

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. (See Chapter 8.)

@ OutputCache

Controls the output caching policies of a page or user control. (See Chapter 18.)

@ Page

Defines page-specific attributes that guide the behavior of the page compiler and the language parser that will preprocess the page.

@ PreviousPageType

Provides a way to get strong typing against the previous page, as accessed through the PreviousPage property.

@ Reference

Links a page or user control to the current page or user control.

@ Register

Creates a custom tag in the page or the control. The new tag (prefix and name) is associated with the namespace and the code of a user-defined control.

With the exception of @Page, @PreviousPageType, @Master, @MasterType, and @Control, all directives can be used both within a page and a control declaration. @Page and @Control are mutually exclusive. @Page can be used only in .aspx files, while the @Control directive can be used only in user control .ascx files. @Master, in turn, is used to define a very special type of page—the master page.

The syntax of a processing directive is unique and common to all supported types of directives. Multiple attributes must be separated with blanks, and no blank can be placed around the equal sign (=) that assigns a value to an attribute, as the following line of code demonstrates:

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

Each directive has its own closed set of typed attributes. Assigning a value of the wrong type to an attribute, or using a wrong attribute with a directive, results in a compilation error.

Important

The content of directive attributes is always rendered as plain text. However, attributes are expected to contain

Return Main Page Previous Page Next Page

®Online Book Reader