Chapter 1: ASP.NET Page Framework


Overview

In this chapter, we’ll examine the ASP.NET page framework, but before we get into the details, let’s look briefly at the big picture and history of Web development. When the user types a URL into the address bar of the browser or clicks on a link, the client Web browser issues a request to the Web server. The Web server processes the request and sends back a page of markup. The client browser receives the markup and renders the page. For most activity on the Web, the markup language is still HTML, but in Chapter 4 we look at how ASP.NET supports Compact HTML (cHTML) and XML vocabularies such as WML and XHTML.

In the early days of Web development, pages on the server were static HTML. The Common Gateway Interface (CGI) was created to provide a way to write programs that could handle client requests and be executed by the Web server. CGI provided great flexibility, enabling developers to create Web applications that could react dynamically based on user input as well as process business logic. However, it also required developers to build complicated programs to deal with all aspects of generating the markup.

The next phase of Web development on Microsoft Windows platforms involved the Internet Server Application Programmer’s Interface (ISAPI), which was introduced to give developers a better means for interacting with the Web server. ISAPI applications are packaged in a DLL on the Microsoft Windows operating system and can be used simultaneously by multiple threads. This was an improvement over CGI on the Windows platform, because the process-per- request overhead was prohibitive. Still, the burden was on the developer to deal with almost all aspects of the client interaction.

Microsoft then introduced Active Server Pages (ASP), which was an ISAPI but didn’t require the developer to write C or C++ code to render HTML. Instead, the developer could use Microsoft JScript or Microsoft Visual Basic Script (VBScript). But it wasn’t just the ability to write pages in an interpreted scripting language that set Active Server Pages apart. ASP also provided a set of intrinsic objects for managing cookies, getting server variables from the Web server, and accessing form data submitted by the user. ASP even managed user sessions automatically. Essentially, it introduced an easy way to manage user state, even though the underlying HTTP protocol was stateless. This was a great leap forward and quickly set a standard for dynamic Web development. However, when you compare this model to the rich rapid application development environment of Visual Basic, ASP seemed lacking.

The Microsoft team tackled the task of taking Web development to the next level by making the environment richer, the intrinsic features more comprehensive, and the platform faster. What came next was Microsoft ASP.NET, which is part of the new Microsoft .NET Framework. Figure 1-1 shows how the common language runtime (CLR), the first layer of the .NET Framework, is built on top of the operating system. The CLR is an execution environment that provides for garbage collection and true language interoperability. Components written for the .NET Framework in one language can easily be utilized from another language. Beyond this, components written for the CLR are free from many of the memory management chores that are the source of various programming problems. The CLR takes intermediate language binaries, and just-in- time (JIT) compiles them for the platform. You no longer need to compile code separately for different versions of Windows; the code will undergo the final machine-specific compilation on demand. Microsoft provides compilers to generate intermediate language files from C#, Visual Basic .NET, Microsoft JScript .NET and Microsoft J# .NET.

click to expand
Figure 1-1: ASP.NET and the .NET Framework

In Figure 1-1 we see that on top of the CLR is a set of libraries that provide much of the base functionality needed to accomplish basic development tasks: threading, input and output, math primitives, and string manipulation. On top of these base class libraries are other features built into the .NET Framework, including socket communications, data access, support for XML, and the System.Web namespaces in which most of the ASP.NET and XML Web Services features exist. The classes of the .NET Framework leverage each other to provide a sophisticated programming platform for developing both server-based and client-based applications.

ASP.NET, as part of the .NET Framework, allows us to use the language of our choice in developing dynamic Web applications and achieve better performance with this compiled code than the equivalent pages written in interpreted script languages. ASP.NET provides an event-driven programming model on top of the stateless HTTP protocol, allowing us to write richer applications with less code.

The page framework uses server controls, objects that encapsulate functionality, and user interface elements. The server controls participate in the life cycle of a Web request and are the building blocks for creating dynamic ASP.NET applications. Previously it would have been necessary to write lots of code to restore the user’s view of the page, but ASP.NET can now carry the data between browser requests and restore it automatically, making the server controls a more powerful primitive for Web development. In Chapter 2 we look more closely at server controls, and in Chapter 3 we focus on server controls for working with data. After that, we look at the mobile page and mobile controls that provide adaptive rendering for targeting browsers in handheld devices and Web-enabled cell phones before looking in more depth at the infrastructure features of ASP.NET.

In addition to the run time features of the ASP.NET page framework and controls, Microsoft Visual Studio .NET provides an environment conducive to rapid application development, including support for source-level debugging of Web applications and IntelliSense statement completion.




Microsoft ASP. NET Coding Strategies with the Microsoft ASP. NET Team
Microsoft ASP.NET Coding Strategies with the Microsoft ASP.NET Team (Pro-Developer)
ISBN: 073561900X
EAN: 2147483647
Year: 2005
Pages: 144

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net