Home > Samples > Update > January 2002
  ASP.NET Improves Development of Web Applications    
   

[Bio]

Microsoft’s ASP.NET constitutes a major change to the Active Server Page (ASP) model, making it significantly easier for developers to create not only dynamic Web content but also intricate and reliable Web applications, such as XML Web services. ASP.NET is a critical piece of the infrastructure for Microsoft’s .NET platform; in order for Microsoft’s .NET vision to succeed, it must convince developers to adopt the .NET Framework and ASP.NET. While beta testers of ASP.NET report substantial benefits, developers will have to address differences in the programming model and language support to convert from ASP to ASP.NET.

What Is ASP.NET?

ASP.NET is the .NET Framework-based platform for developing Web applications that are hosted on Microsoft’s Internet Information Server (IIS) and use Internet protocols such as Hypertext Transfer Protocol (HTTP) and Simple Object Access Protocol (SOAP). ASP.NET facilitates the development and deployment of two kinds of Web applications:

  • Web Form applications that include dynamic content, including Web pages that expose a user interface (UI) to a thin client, such as a browser
  • XML Web services that expose functionality to other applications and "smart" clients, and allow applications to exchange information.

Both kinds of Web applications share one main advantage over traditional applications: they use Internet-based protocols to allow information to move as easily across organizational boundaries (and firewalls) as it moves within an organization.

ASP.NET's Main Mission

The primary mission of ASP.NET is to significantly lower the barrier to the development of Web applications. It accomplishes this mission in much the same way that Visual Basic lowered the barrier to Windows programming: by implementing an "event-driven" programming model in which developers add controls to a form and write code to handle the events (e.g., the entry of data in a text box or the clicking of a button) associated with these controls. It also makes it easier for developers to build services that exchange data in XML by allowing developers to build on the XML support exposed by the .NET Framework class libraries.

Microsoft previously attempted to lower the barrier to Web application development with ASP, which was first introduced as a feature of IIS 3.0 in 1996. ASP supported VBScript and JavaScript and some simple objects that could be used for Web application development, such as a request object that allows developers to get data from the client and a response object to send data to the client. ASP was easier to use for Web application development than previous IIS APIs, such as the Common Gateway Interface (CGI) and the Internet Server Application Programming Interface (ISAPI). With ASP, a programmer with HTML and scripting experience could easily develop dynamic Web content.

However, developing a powerful and stable Web Form or service was still too difficult due to the limited object model, limited capabilities of the scripting languages, limited tools for end-to-end application debugging, and the requirement to make API-level calls to external XML toolkits and parsers.

ASP.NET and the .NET Framework

By using the .NET Framework for ASP.NET, Microsoft provides developers with the benefits of the Common Language Runtime (CLR) and class libraries.

ASP.NET uses the CLR to compile code and manage its execution, creating Web applications that run faster and behave better. (For a graphical representation of the components of ASP.NET and the .NET Framework, see the illustration "ASP.NET Architecture".)

Relatedly, ASP.NET uses the .NET Framework classes to make it easier for developers to incorporate XML-formatted data into Web applications, and to add code to handle exceptions, create UI elements, and provide other programmatic functionality. (For more information on the .NET Framework, see ".NET Framework Forces Decisions" on page 3 of the Oct. 2001 Update.)

ASP.NET and the .NET Vision

Finally, ASP.NET plays an important part in Microsoft's overall .NET vision. Over the next decade, Microsoft believes that the PC will be augmented by many other types of devices that can access the Internet, from handheld devices to mobile phones to home entertainment devices (such as gaming machines and TV set-top boxes). So-called smart clients running on these devices will take advantage of their considerable processing power to perform device-specific tasks—for example, using speech recognition in an automotive PC.

Although ASP.NET will initially be used like ASP to quickly develop and deploy Web applications for thin clients running on PCs (i.e., Web browsers), Microsoft sees it eventually being used to host more complex applications (such as XML Web services) that target smart clients running on all types of devices.

Benefits of ASP.NET

ASP.NET offers significant improvements over ASP in three areas: the programming model, state management, and benefits inherited from the .NET Framework.

Event-Driven Programming Model

Event-driven programming allows developers to create code that will execute when a particular event occurs. For example, in the case of ASP.NET, a particular segment of code can be executed when a page is either loaded or unloaded, or a control on a page is clicked. In contrast, ASP uses a linear code-processing model: each line of ASP code is mingled with static HTML and is processed in the order in which it appears in the ASP file.

Event-driven programming makes ASP.NET programming more closely parallel Windows programming. The advantages come from the fact that developers only need to write code to respond to events, and they can extend their knowledge of event-driven programming from the development of Windows desktop applications to Web applications.

Another advantage of the event-driven programming model is that it allows for separation of the code that manipulates the data from the code that presents the data to the user. For example, ASP.NET allows developers to use a mechanism called "code behind" to separate the logic of the Web application (typically written in VB.NET or C#) from the presentation (typically formatted by HTML). By separating the logic into a VB or C# (pronounced "C-sharp") code file (*.aspx.vb or *.aspx.cs) and a presentation code file (*.aspx), ASP.NET allows multiple pages to use the same code, and makes maintenance easier because developers need not search through HTML statements in order to fix a programming logic problem. (See the illustration "Code Behind".)

Better State Management

ASP.NET provides substantial benefits for Web application state management. State management involves tracking each user’s session data, which is the unique temporary information generated by users during their interaction with a Web site— for example, the items currently in a user’s shopping cart or whether the user is currently logged on to the site.

ASP.NET solves two problems related to state management. First, state information was often lost if there was a problem with the Web site server, and second, it was hard to manage state information on Web sites hosted on a group of servers or a Web farm.

As with ASP, state information can be maintained within the process in which ASP.NET is running. While this method provides the best performance, it is also the least stable and scalable: if the server is restarted, stored state information is lost, and in-process state management cannot be provided to a Web application hosted on multiple servers.

Unlike ASP, ASP.NET can also use a Windows Service (ASPState) for out-of-process state management. While somewhat slower than in-process state management, this allows information to be maintained even if the ASP.NET process is restarted, and it can support Web applications that span multiple servers in a Web farm.

A third alternative for state management allows ASP.NET to store the state information in Microsoft SQL Server. Using SQL Server also ensures that state information survives problems on the Web server, and a SQL Server can store the state for Web applications hosted on a Web farm.

Benefits from the .NET Framework

ASP.NET makes it easier for developers to create Web pages with a UI by using the .NET Framework class libraries, which provide controls such as text and list boxes, and a variety of buttons. Developers use these controls by inserting tags (e.g., <asp:Button>) into their dynamic Web pages or by using the graphical page editor of Visual Studio.NET. ASP.NET provides several types of controls:

  • Server-side versions of existing HTML controls such as a button (HTMLButton) and radio button (HTMLInputRadioButton) control. The main difference between existing HTML tags for forms and ASP.NET HTML controls is the "runat=server" attribute, which means that code executes on the server to expose the control on the client.
  • Web Form controls, which are server-side controls that duplicate some of the HTML controls, plus add new and more complex controls such as text boxes (<asp:TextBox>), list boxes, calendars, and data grids. These controls are easier to use than HTML controls in that properties such as size are used in a consistent manner across all of the controls.
  • Validation controls, which are controls that link to both HTML controls and Web Form input controls (such as text boxes). Validation controls can validate user input by performing a comparison, checking the range of the input, or applying a custom validation code.

All of these controls reduce the amount of code that developers have to write; the developer need only position the control on a page, initialize the control’s properties and methods, and then write code to respond to events the control might generate as a result of some action by the user (such as clicking on a button). These controls also support data binding so that a developer can easily associate the values assigned to a control with specific information retrieved from a database.

In contrast, ASP provided only six elementary controls, and while ActiveX controls could be used with ASP, this often made Web applications less stable.

In addition, the .NET Framework class libraries offer general benefits for any Windows application—not just Web applications. Among these benefits are the following:

Less coding for exception handling. The .NET Framework exception-handling classes easily allow developers to include code to handle common programming problems, such as divide-by-zero, out-of-memory, or file-not-found errors.

Less coding for data exchange. By using the .NET Framework class libraries, ASP.NET developers can easily read and write XML data streams. ASP.NET can also use ADO.NET, a new and extended set of Active Data Objects (ADO) to manage the connection to and manipulation of data in a database.

Improved performance. ASP.NET performs substantially better than ASP, primarily because code targeting the CLR is compiled (while the script languages in ASP are interpreted). Initial page loads may be slower, as the code is compiled on first use, but for subsequent page requests, the page is served from the compiled code in a dynamic output cache. ASP.NET can even partially cache a page, recognizing changes to control events or query strings in cached pages. Even the performance of beta versions of ASP.NET appear to be substantially faster than ASP. (For a comparison provided by Microsoft, see the illustration "ASP.NET Performance".)

Increased language support. ASP.NET allows developers to use any language supported by the CLR, including the new languages VB.NET and C#. ASP supported only the VBScript and JScript interpreted scripting languages.

Improved debugging support. Developers of ASP.NET-based Web applications can use either the .NET Framework debugger or the debugger integrated into Visual Studio.NET. In addition to allowing developers to step through code and set break points, ASP.NET also supports tracing, which allows developers to trace the execution of an application and later view the results of the trace. To debug ASP pages, developers often had to sprinkle their code with custom "Response.Write" statements to show themselves the value of a variable at a particular point in the application. After debugging, these lines of code had to be removed or commented out so that they would not output debug information when the application was running in production. Tracing can be turned on and off easily and can be performed with either an individual Web page or Web application-wide scope.

Getting to ASP.NET

The differences between ASP and ASP.NET make it impossible to run existing ASP pages on ASP.NET. However, the two can run side by side without any problems; that is, a single IIS server can host both ASP and ASP.NET-based Web applications.

Developers wanting to exploit ASP.NET have several choices:

  • Leave existing ASP applications alone, and develop new applications on ASP.NET. Because ASP and ASP.NET coexist, there is no pressing need to convert existing applications to ASP.NET. But given the significant advantages of ASP.NET, developers will probably not want to develop any new applications for ASP.
  • Add ASP.NET features to existing ASP Web applications. Conceptually, developers could build an application with a mixture of ASP and ASP.NET pages, allowing gradual migration of the application to ASP.NET. However, state management cannot be split between ASP and ASP.NET, which may make this approach impractical when state information has to be shared between an ASP and ASP.NET page.
  • Convert existing ASP Web applications to ASP.NET. This will require developers to convert existing script-based code to either VB.NET or C#, convert from ADO to ADO.NET, and add event-driven code to the application. Careful examination of the existing application to determine how much script-code is embedded in the pages, and the new advantages of ASP.NET, such as server-side controls and the event model, will reveal if this approach makes sense.
  • Rewrite existing ASP Web applications for ASP.NET, using the existing pages as a proof-of-concept specification and re-creating both the presentation and the logic of the pages to take full advantage of ASP.NET features. This approach may take the most effort, but might also yield the best results in terms of application stability and performance.

Availability and Resources

The benefits of ASP.NET can be substantial, so much so that during the beta of ASP.NET, beta testers successfully lobbied Microsoft to license the beta ASP.NET code so that developers could put their ASP.NET Web applications into production. This is the first time Microsoft has officially allowed customers to use beta code in production.

A full release of ASP.NET will likely coincide with and be a part of Visual Studio.NET, which is scheduled for release in Feb. 2002. ASP.NET is also distributed with the .NET Framework SDK.

Requirements

ASP.NET is supported on Windows 2000 (Professional, Server, and Advanced Server) and Windows XP Professional, for both client and server applications.

To develop ASP.NET server applications, the following software is required:

  • Windows 2000 Server or Advanced Server with Service Pack 2
  • Windows XP Professional or 64-Bit Edition
  • MDAC 2.7
  • Internet Information Server

Resources

For more information on .NET, Web applications, and Web services, see the July 2001 Research Report, "Understanding .NET."

For the current beta of ASP.NET, see http://msdn.microsoft.com/downloads/default.asp?URL=/code/sample.asp?url=/MSDN-FILES/027/001/659/msdncompositedoc.xml.

For information on ASP.NET, see www.asp.net, www.gotdotnet.com and http://msdn.microsoft.com/library/default.asp?url=/nhp/Default.asp?contentid=28000440.