ASP.NET Web Forms

The main building blocks of Web Forms pages are server controls, which are reusable components responsible for rendering HTML markup and responding to events.

With ASP.NET Framework 2.0, Microsoft introduced a new code-behind model that lets static text remain on the .aspx page while dynamic code goes into an .aspx.vb or .aspx.cs or .aspx.fs file (depending on the programming language used).

This practice is automatic in Visual Studio and other IDEs, though the user can change the code-behind page name.

[8] When using this style of programming, the developer writes code to respond to different events, such as the page being loaded, or a control being clicked, rather than a procedural walkthrough of the document.

ASP.NET's code-behind model marks a departure from Classic ASP in that it encourages developers to build applications with separation of presentation and content in mind.

This is a source of confusion among novice ASP.NET programmers who rely on the class instance members that are lost with every page request/response cycle.

State management in ASP.NET pages with authentication can make Web scraping difficult or impossible.

The variables can be set to be automatically destroyed after a defined time of inactivity even if the session does not end.

View state is turned on by default and normally serializes the data in every control on the page regardless of whether it is actually used during a postback.

This behavior can (and should) be modified, however, as View state can be disabled on a per-control, per-page, or server-wide basis.

Encryption can be enabled on a server-wide (and server-specific) basis, allowing for a certain level of security to be maintained.

While this allows for common elements to be reused across a site, it adds complexity and mixes source code with markup.

Other developers have used include files and other tricks to avoid having to implement the same navigation and other elements in every page.

[13] Master templates have place-holder controls, called ContentPlaceHolders to denote where the dynamic content goes, as well as HTML and JavaScript shared across child pages.

This means that the content page may still manipulate headers, change title, configure caching, etc.

Other file extensions associated with different versions of ASP.NET include: In general, the ASP.NET directory structure can be determined by the developer's preferences.

The special directory names (from ASP.NET 2.0 on) are:[16] ASP.NET aims for performance benefits over other script-based technologies (including Classic ASP) by compiling the server-side code the first time it is used to one or more DLL files on the Web server.

This feature provides the ease of development offered by scripting languages with the performance benefits of a compiled binary.

Developers can also choose to pre-compile their "codebehind" files before deployment, using Microsoft Visual Studio, eliminating the need for just-in-time compilation in a production environment.

A Web control, such as a button or label, functions in very much the same way as its Windows counterparts: code can assign its properties and respond to its events.

ASP.NET WebForms encourages the programmer to develop applications using an event-driven GUI model, rather than in conventional Web-scripting environments like ASP and PHP.

The framework combines existing technologies such as JavaScript with internal components like "ViewState" to bring persistent (inter-request) state to the inherently stateless Web environment.