Each .aspx page, or ASP.NET web forms, has three sections. The first section is the Page directive:

C# 8.0 and .NET Core 3.0 – Modern Cross-Platform Development: Build applications with C#, .NET Core, Entity Framework Core, ASP.NET Core, and ML.NET using Visual Studio Code, 4th Edition
ASP.NET Core 3 and Angular 9: Full stack web development with .NET Core 3.1 and Angular 9, 3rd Edition
C# in Depth, 4th Edition

<%@ Page Language=”C#” AutoEventWireup=”true” CodeFile=”Default.aspx.cs” Inherits=”_Default” %>

The page directive gives ASP.NET basic information about how to compile the page. It indicates:

– the language you’re using for your code

– the way you connect your event handlers.

If you’re using the recommended code-behind approach, the page directive points:

– where the code file is located

– the name of your custom page class.


1. You don’t need to modify the page directive by hand, because Visual Studio 2010 maintains it for you.

2. The page directive doesn’t appear in the HTML that’s sent to the browser—instead, ASP.NET strips it out.