ASP.NET is a web application framework marketed by Microsoft that programmers can use to build dynamic web sites, web applications and XML web services. It is part of Microsoft's .NET platform and is the successor to Microsoft's Active Server Pages (ASP) technology.
ASP.NET is built on the Common Language Runtime, meaning programmers can write ASP.NET code using any Microsoft .NET language.
ASPX is a text file format used to create Webform pages; in programming jargon, the ASPX file typically contains static HTML or XHTML markup, as well as markup defining Web Controls and Web User Controls where the developers place all the required static and dynamic content for the web page. Additionally, dynamic code which runs on the server can be placed in a page within a block
<% -- dynamic code -- %>which is similar to other web development technologies such as PHP, JSP, and ASP, but this practice is generally frowned upon by Microsoft except for the purposes of data binding since it requires more calls when rendering the page.
The method recommended by Microsoft for dealing with dynamic program code is to use the code-behind model, which places this code in a separate file or in a specially designated script tag. Code-behind files are typically named something to the effect of MyPage.aspx.cs or MyPage.aspx.vb based on the ASPX file name (this practice is automatic in Microsoft Visual Studio and other IDEs). When using this style of programming, the developer writes code to respond to different events, like the page being loaded, or a control being clicked, rather than a procedural walk through the document.
ASPX file format
ASP.NET uses a visited composites rendering technique. During compilation the template (.aspx) file is compiled into initialization code which will build a control tree (the composite) representing the original (static) template. Literal text goes into instances of the Literal control class, server controls are represented by instances of a specific control class. The initialization code is combined with user-written code (usually by the assembly of multiple partial classes) and results in a class specific for the page. The page doubles as the root of the control tree.
Actual requests for the page are processed through a number of steps. First, during the initialization steps, an instance of the page class is created and the initialization code is executed. This produces the initial control tree which is now typically manipulated by the methods of the page in the following steps. As each node in the tree is a control represented as an instance of a class, the code may change the tree structure as well as manipulate the properties/methods of the individual nodes. Finally, during the rendering step a visitor is used to visit every node in the tree, asking each node to render itself using the methods of the visitor.
After the request has been processed, the instance of the page class is discarded and with it the entire control tree.
Other file extensions associated with different versions of ASP.NET include:
Global.asax, used for application-level logic and event handling
Web UserControls: custom controls to be placed onto web pages.
custom HTTP handlers
web service pages.
when enabled in web.config requesting trace.axd outputs application-level tracing. Also used for the special webresource axd handler which allows control/component developers to package a component/control complete with images, script, css etc. for deployment in a single file (an 'assembly')
browser capabilities files stored in XML format; introduced in version 3.0. ASP.NET 2 includes many of these by default, to support common web browsers. These specify which browsers have which capabilities, so that ASP.NET 2 can automatically customize and optimize its output accordingly. Special .browser files are available for free download to handle, for instance, the W3C Validator, so that it properly shows standards-compliant pages as being standards-compliant. Replaces the harder-to-use BrowserCaps section that was in machine.config and could be overridden in web.config in ASP.NET 1.x.
web.config is the only file in a specific Web application to use this extension by default (machine.config similarly affects the entire Web server and all applications on it), however ASP.NET provides facilities to create and consume other config files. These are stored in XML format, so as to allow configuration changes to be made with simplicity.
In ASP.NET 2 any cs/vb files placed inside the App_Code folder are dynamically compiled and available to the whole application.
Master Pages; introduced in version 2.0
sitemap configuration files
theme skin files.
resource files for internationalization and localization. Resource files can be global (for e.g. messages) or "local" which means specific for a single aspx or ascx or file.
In general the ASP.NET developer is free to create his/her own directory structure. Apart from a few reserved directory names the site can span any number of directories. The structure is typically reflected directly in the urls. Although ASP.NET provides means for intercepting the request at any point during processing, the developer is not forced to funnel requests through a central application or front controller.
The special directory names are:
holds site-specific browser definition files.
This is the "raw code" directory. The ASP.NET server will automatically compile files (and subdirectories) in this folder into an assembly which is accessible in the code of every page of the site. App_Code will typically be used for data access abstraction code, model code and business code. Also any site-specific http handlers and modules and web service implementation go in this directory. As an alternative to using App_Code the developer may opt to provide a separate assembly with precompiled code.
default directory for databases, such as Access mdb files and SQL Server mdf files. This directory is usually the only one with write access for the application.
Contains localized resource files for individual pages of the site. E.g. a file called CheckOut.aspx.fr-FR.resx holds localized resources for the french version of the CheckOut.aspx page. When the UI culture is set to french, ASP.NET will automatically find and use this file for localization.
Holds resx files with localized resources available to every page of the site. This is where the ASP.NET developer will typically store localized messages etc. which are used on more than one page.
holds alternative themes of the site.
holds discovery files and WSDL files for references to web services to be consumed in the site.
ASP.NET aims for performance benefits over other script-based technologies (including ASP Classic) by compiling the server-side code to one or more DLL files on the web server. This compilation happens automatically the first time a page is requested (which means the developer need not perform a separate compilation step for pages). This feature provides the ease of development offered by scripting languages with the performance benefits of a compiled binary. However, the compilation might cause a noticeable delay to the web user when the newly-edited page is first requested from the web server.
The ASPX and other resource files are placed in a virtual host on an Internet Information Services (or other compatible ASP.NET servers; see Other Implementations, below). The first time a client requests a page, the .NET framework parses and compiles the file(s) into a .NET assembly and sends the response; subsequent requests are served from the dll files. By default ASP.NET will compile the entire site in batches of 1000 files upon first request. If the compilation delay is causing problems, the batch size or the compilation strategy may be tweaked.
Developers can also choose to pre-compile their code before deployment, eliminating the need for just-in-time compilation in a production environment.
Other differences compared to ASP classic are:
Compiled code means applications run faster with more design-time errors trapped at the development stage.
Significantly improved run-time error handling, making use of exception handling using try-catch blocks.
Similar metaphors to Windows applications such as controls and events, which make development of rich user interfaces, previously only found on the desktop, possible.
An extensive set of controls and class libraries allows the rapid building of applications, plus user-defined controls allow commonly used templates, such as menus. Layout of these controls on a page is easier because most of it can be done visually in most editors.
ASP.NET leverages the multi-language capabilities of the .NET CLR, allowing web pages to be coded in VB.NET, C#, J#, etc.
Ability to cache the whole page or just parts of it to improve performance.
Ability to use the code-behind development model to separate business logic from presentation.
If an ASP.NET application leaks memory, the ASP.NET runtime unloads the AppDomain hosting the erring application and reloads the application in a new AppDomain.
Session state in ASP.NET can be saved in a SQL Server database or in a separate process running on the same machine as the web server or on a different machine. That way session values are not lost when the web server is reset or the ASP.NET worker process is recycled.
Web Server Controls: these are controls introduced by ASP.net for providing the UI for the web form. These controls are state managed controls and are WYSIWYG (What You See Is What You Get) controls. ASP.NET compared to ASP classic
Active Server Pages Classic (ASP) and ASP.NET can be run side-by-side in the same web application. This approach allows developers to migrate applications slowly instead of all at once. On IIS 6.0 and lower, pages written using different versions of the ASP framework can't share Session State without the use of third-party libraries. This criticism does not apply to ASP.NET and ASP applications running side by side on IIS 7. With IIS 7, modules may be run in an integrated pipeline that allows modules written in any language to be executed for any request.
In some cases ASP.NET runtime will recycle the worker process (e.g. if it becomes unresponsive or if an application runs amok and causes the worker process to use more than 60% of available RAM). It can also be configured to recycle the process proactively after a certain number of requests, time period etc. In these cases users may lose session state if the application is configured to use in-process sessions. If the application relies on session state to store authentication information (bad practice since cookie based authentication and membership is built into the framework) and the application is configured to use in-process sessions, the user may be logged out if the process is recycled.
Criticisms of ASP.NET
Fact: ASP.NET (and indeed, .NET as such) applications executes fully compiled. The misconception stems from the fact that this compilation is a two-step process, where ASP.NET is first compiled into intermediate language (IL). This can be done using a compiler such as the C# compiler. Only just before actual execution on the target machine does the .NET CLR take over and compile the IL into machine instructions optimized for the target architecture. The developer has no control of this process. The ASP.NET runtime will then cache the compiled code for subsequent executions.
Fact: ASP.NET is a highly abstracted framework for web development with feature rich components (widgets). Visual Studio will assist in configuring properties for these widgets, but in general they come with good defaults. Hence, VS has editors for special file formats, but no code generation in the sense that it spews out C# or VB.NET code which must be manually edited to suit different needs afterwards with the risk of losing custom changes when the code needs to be once again generated. In a number of places ASP.NET relies on metaprogramming, examples of this are: Compiling an .aspx markup file into a partial class, compiling a XML schema (representing a dataset) into .NET classes. One exception where code generation could be said to take place is when you define a dataset from an existing database by dragging and dropping tables from the database schema to the XML schema file.
Fact: An ASP.NET web site/application can easily be created using any text editor. Since compilation is handled by the server the markup files can be uploaded as source code to the server. Documentation (or experience) will be required to use the web controls/widgets in this way.
Misconception: "ASP.NET is interpreted or semi-interpreted"
Misconception: "ASP.NET relies heavily on code generation"
Misconception: "ASP.NET relies heavily on Visual Studio" Common misconceptions
Several available software packages exist for developing ASP.NET applications:
Microsoft Expression Web, part of the Microsoft Expression Studio application suite.
Visual Studio .NET or Visual Studio 2005 or Visual Web Developer 2005 Express Edition (for ASP.NET 2.0)
ASP.NET Web Matrix (ASP.NET 1.x only, was free, now no longer supported: replaced by the free Visual Web Developer 2005 Express Edition)
Macromedia Dreamweaver MX, Macromedia Dreamweaver MX 2004, or Macromedia Dreamweaver 8 (doesn't support ASP.NET 2.0 features, and produces very inefficient code for ASP.NET 1.x: also, code generation and ASP.NET features support through version 8.0.1 was little if any changed from version MX: version 8.0.2 does add changes to improve security against SQL injection attacks)
Macromedia HomeSite 5.5 (For ASP Tags)
Microsoft SharePoint Designer 12
MonoDevelop (Free/Open Source)
SharpDevelop (Free/Open Source) History
Various ASP.NET team members maintain blogs. Here are some of them:
Scott Guthrie, General Manager - http://weblogs.asp.net/scottgu
Nikhil Kothari, Architect - http://www.nikhilk.net
Brian Goldfarb, Product Manager - http://blogs.msdn.com/bgold
Shanku Niyogi, Product Unit Manager - http://www.shankun.com
Bertrand Le Roy, Developer - http://weblogs.asp.net/bleroy
Harish Ranganathan, Developer Evangelist - http://geekswithblogs.net/ranganh ASP.NET team members
Active Server Pages (ASP) – ASP.NET's predecessor
ASP master pages
Yellow Screen of Death – ASP.NET's Exception page
Java Server Faces (JSF) – web application technology with a similar component based approach for the Java plattform
ASP.NET AJAX – Extension for AJAX enabled ASP.NET pages See also
Pro ASP.NET 2.0 in C# 2005, Matthew MacDonald, Apress, November 27, 2005. ISBN 1-59059-496-7
ASP.NET 2.0 Unleashed, Stephen Walther, Sams Publishing, June 6, 2006. ISBN 0-672-32823-2
Essential ASP.NET With Examples in C#, Fritz Onion, Addison-Wesley Professional, February 11, 2003. ISBN 0-201-76040-1
Programming ASP.NET, Jessy Liberty & Dan Hurwitz, O'Reilly, October, 2005. ISBN 0-596-00916-X
ASP.NET 2.0 Website Programming , Marco Bellinaso, Wrox, May, 2006. ISBN 0-7645-8464-2 Resources about ASP.NET
Mono - An open source .NET Framework implementation that runs on many platforms
UltiDev Cassini Web Server - A free web server that can be redistributed with ASP.NET 1.1 and 2.0 applications Links about ASP.NET Providers
Microsoft's ASP.NET 2.0 website
ASP.NET on MSDN
CSS friendly ASP.NET 2.0 control adapters
Visual Web Developer Express Edition 2005
Visual Web Developer Express Edition 2005 SP1 Download
Microsoft Expression Web Designer (Standards-compliant css-based design)