Server-Side Include Directives — Global.asax
File inclusion directives can be used in Global.asax or in any ASP.NET application file. A #include directive can insert the raw contents of a specified file into an ASP.NET application file. The syntax is that of an HTML comments tag, as follows:
<!-- #include pathtype = filename -->
Parameters
- pathtype
The path type of the file identified by the filename parameter. - filename
The name of the file whose contents are to be included in the ASP.NET application file. The filename parameter must contain the file name extension, and you must enclose the file name plus extension in quotation marks.
Attributes
The path type can be one of the following two attributes.
- file
Indicates that the filename parameter is a relative path from the directory containing the file with the #include directive. The included file can be in the same directory or in a subdirectory; it cannot be in a directory above the file with the #include directive. - virtual
Indicates that the filename parameter is a full virtual path from a virtual directory on your Web site.
Remarks
The included file is processed before any dynamic code is executed. The tag containing the #include directive must use HTML or XML comment delimiters to avoid being interpreted as static text.
Example
The following example demonstrates including a file named MyHeader.inc
in a Web Forms page.
<!-- #include File = "MyHeader.inc" -->