New ASP.NET Page Directives

In previous versions of ASP, it was possible to place a single directive on the first line of a page. For example:

<%@LANGUAGE="VBScript" CODEPAGE="932"%>

Several new directives have been added to ASP.NET. The Language attribute must now be placed within an @Page directive, as shown in the following example.

   <%@Page Language="VB" Codepage="932"%>
   <%@OutputCache Duration="10 VaryByParam="location"%>

For migration purposes, the shorter ASP-style syntax is also supported for the Page directive only.

   <%@ Language="VB" Codepage="932"%>
   <%@OutputCache Duration="10 VaryByParam="location"%>

Directives can be located anywhere in an .aspx file, but standard practice is to place them at the beginning of the file. Case is not important in ASP.NET directive statements, and quotes are not required around the attribute values. The @ Page directive shown in the preceding example can also be written as follows:

<%@PAGE LANGUAGE=VB CODEPAGE=932%>

For more information about the new directives and their attribute sets, see Directive Syntax.

See Also

Directive Syntax | Migrating ASP Pages to ASP.NET