In a single-file page, the markup, server-side elements, and event-handling code are all in a single .aspx file. When the page is compiled, the compiler generates and compiles a new class that derives from the base Page class or a custom base class defined with the Inherits attribute of the @ Page directive. For example, if you create a new ASP.NET Web page named SamplePage1 in your application's root directory then a new class named ASP.SamplePage1_aspx is derived from the Page class. For pages inside of application subfolders, the subfolder name is used as part of the generated class. The generated class contains declarations for the controls in the .aspx page and contains your event handlers and other custom code.
After page generation, the generated class is compiled into an assembly, the assembly is loaded into the application domain, and then the page class is instantiated and executed to render output to the browser. If you make changes to the page that would affect the generated class—whether by adding controls or modifying your code—the compiled class code is invalidated and a new class is generated. For more information on compilation in ASP.NET, see ASP.NET Compilation Overview.
The following illustration shows the inheritance model for the page class in a single-file ASP.NET Web page: