---
title: "Directives in ASP.NET"  
description: "@Page: Defines page-specific attributes used by the ASP.NET page parserand compiler. Can   be included only in .aspx files     @Control:Defines contro"  
author: "Amit Singh"  
published: 2010-11-06  
updated: 2014-09-18  
canonical: https://www.mindstick.com/blog/44/directives-in-asp-dot-net  
category: "asp.net"  
tags: ["asp.net"]  
reading_time: 2 minutes  

---

# Directives in ASP.NET

**@Page**: Defines page-specific [attributes](https://www.mindstick.com/articles/13105/2-attributes-that-make-your-odoo-ecommerce-theme-productive-and-engaging) used by the ASP.NET page parserand compiler. Can be included only in .aspx files <%@ Page AspCompat="TRUE" language="C#" %> \

\
**@Control**:Defines control-specific attributes used by the ASP.NET page parser and compiler. Can be included only in .ascx files. <%@ Control Language="VB" [EnableViewState](https://www.mindstick.com/interview/734/what-does-the-enableviewstate-property-signify)="false" %>\
\
**@Import**: Explicitly imports a namespace into a page or [user control](https://www.mindstick.com/forum/294/problem-in-access-the-control-inside-the-user-control). The Import directive cannot have more than [one namespace](https://www.mindstick.com/forum/206/can-db2-be-used-in-asp-dot-net-and-which-one-namespace-used-for-db2) attribute. To import multiple [namespaces](https://www.mindstick.com/forum/155583/what-are-namespaces-in-c-sharp), use multiple @Import directives. <% @ Import Namespace="System.web" %>\
\
**@Implements**: Indicates that the current page or user control implements the specified .NET [framework](https://www.mindstick.com/forum/34615/software-framework-vs-library) [interface](https://www.mindstick.com/articles/12101/interfaces-in-java-extending-interfaces).<%@ Implements Interface="System.Web.UI.IPostBackEventHandler" %>\
\
**@Register**: Associates aliases with namespaces and class names for concise notation in custom server control syntax.<%@ Register Tagprefix="Acme" Tagname="AdRotator" Src="AdRotator.ascx" %>\
\
**@Assembly**: Links an assembly to the current page during [compilation](https://www.mindstick.com/interview/358/which-is-the-first-level-of-compilation-in-the-dot-net-languages), making all the assembly's classes and [interfaces](https://www.mindstick.com/articles/12100/interfaces-in-java-real-life-example) available for use on the page. <%@ Assembly Name="MyAssembly" %><%@ Assembly Src="MySource.vb" %>\
\
**@OutputCache**: Declaratively controls the [output caching](https://answers.mindstick.com/qa/51751/what-is-output-caching-in-web-application) policies of an ASP.NET page or a user control contained in a page<%@ OutputCache Duration="#ofseconds" Location="Any | Client | Downstream | Server | None" Shared="True | False" VaryByControl="controlname" VaryByCustom="browser | customstring" VaryByHeader="headers" VaryByParam="parametername" %>\
\
**@Reference**: Declaratively indicates that another user control or page source file should be dynamically compiled and linked against the page in which this directive is declared.\

---

Original Source: https://www.mindstick.com/blog/44/directives-in-asp-dot-net

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
