CodeNotes for ASP.NET

CodeNotes for ASP.NET

by Gregory Brill

View All Available Formats & Editions

CodeNotes provides the most succinct, accurate, and speedy way for
a developer to ramp up on a new technology or language.
Unlike other programming books, CodeNotes drills down to
the core aspects of a technology, focusing on the key elements needed in order to implement it immediately. It is a unique resource for
developers, filling the gap between… See more details below


CodeNotes provides the most succinct, accurate, and speedy way for
a developer to ramp up on a new technology or language.
Unlike other programming books, CodeNotes drills down to
the core aspects of a technology, focusing on the key elements needed in order to implement it immediately. It is a unique resource for
developers, filling the gap between comprehensive manuals and
pocket references.

CodeNotes for ASP.NET is a revolutionary update to Microsoft’s Active Server Pages. This edition explores how Web applications and Web services can be developed using ASP.NET. The .NET architecture, Base Class Libraries, ASP.NET form designer,
Web controls, and cross-page and cross-language debugging
are discussed. Scaling ASP.NET to multiple servers,
state management, security, and methods of enhancing performance are also covered.
This edition of CodeNotes includes:

• Real-world examples
• “How and Why” and “Bugs and Caveats” sections that provide
workarounds and tips on what should be taken advantage
of or avoided
• “Design Notes” illustrating many of the common use patterns for
Java programs
• Instructions and classroom-style tutorials throughout from experts

Visit for updates, source code templates, access to
message boards, and discussion of specific problems with
CodeNotes authors and other developers.

Join our nonfiction newsletter by sending a blank e-mail to: or visit

Every CodeNotes title is written and reviewed by a team of commercial software developers and technology experts. See “About the Authors” at the front of the book for more information.

From the Trade Paperback edition.

Read More

Product Details

Random House Publishing Group
Publication date:
Codenotes Series
Sold by:
Random House
File size:
8 MB

Related Subjects

Read an Excerpt

Chapter 1

INTRODUCTION ASP.NET is Microsoft’s new technology for developing web-based applications. The most significant feature of ASP.NET (formerly named ASP+) is that it allows you to develop web applications using the intuitive drag-and-drop methodology that made Visual Basic popular. Simply “paint” your application within an intuitive development environment, and it will look and behave identically when deployed on a client’s browser. In addition to this noteworthy capability, ASP.NET boasts a number of improvements over the traditional Active Server Page (ASP) technology that you may be using today. These improvements, which we will examine throughout this book, are listed below.


The languages used to write traditional ASP applications (VBScript and JScript) have two primary limitations. First, they are inherently typeless, meaning that they have no concept of variable types. For example, in VBScript all variables are implicitly Variants—there is no way to declare a variable as a more specific Integer or String. Second, these languages are interpreted, meaning that ASP translates an application’s source on a line-by-line basis. If the fiftieth line of the application contains a syntax error, ASP must process the first forty-nine lines before the error will be detected.

With ASP.NET, applications are developed using strongly typed languages such as Visual Basic, C++, JScript.NET, or Microsoft’s new language, C# (pronounced “C-sharp”). Furthermore, applications in ASP.NET are compiled, which means that the entire source file is quickly examined and converted into machine code before the application is executed. Compiled applications are not only significantly faster than their interpreted counterparts, they are also easier to debug since syntax errors can be caught at compile time (while you are developing), as opposed to runtime (when the application executes).


Another cumbersome aspect of ASP development is the interspersion of source code with HTML. Because ASP scripts contain both code and HTML, source files are often lengthy, difficult to read, and hard to debug. The intermixing of HTML with ASP code is particularly problematic for larger web applications, where content must be kept separate from business logic.

ASP.NET eliminates this problem by keeping the design and programmatic aspects of your application separate. One file contains the application’s design (the HTML), whereas another file, called the CodeBehind file, houses its associated logic (the source code). Thus, developers can work on the application’s code while designers and graphic artists independently work on its content.


Supporting multiple browsers is a recurrent and persistent problem when developing web applications. ASP.NET eliminates this concern through its Web Control technology. A Web Control is a graphical entity very similar to an intrinsic control found in Visual Basic 6 (such as a Textbox or Button). Like its Visual Basic counterpart, a Web Control exposes a rich event model that you program against (such as a TextChanged() event, which triggers when the contents of the control change).

What is important about Web Controls is that they reside entirely on the server and generate client-side and server-side code to render themselves appropriately in a browser. In the eyes of ASP.NET, a browser can be one of two types: An UpLevel browser, defined as Internet Explorer 4.0 or higher; or a DownLevel browser, defined as everything else (including all versions of Netscape).

If the browser is UpLevel, then the control generates client-side JavaScript so that events can be trapped directly on the client. If the browser is of the DownLevel type, then the control generates standard HTML, which requires a round-trip to the server to trigger events. We will examine Web Controls, and this seemingly unfair browser classification, in Chapter 5.


Microsoft’s new development environment, Visual Studio.NET (VS.NET), allows you to develop web applications as you do in Visual Basic 6—by dragging and dropping GUI elements onto a base form and then writing the logic behind the controls. In addition, Visual Studio.NET offers sophisticated debugging features such as breakpoints, variable inspection, compile-time error checking, and code-stepping capabilities.

VS.NET is the development environment not only for ASP.NET applications, but for all applications that leverage .NET technology (such as component libraries that your web applications might utilize). Such uniformity allows you to debug both ASP.NET applications and the components they call from the same environment. As we will illustrate in Chapter 6, you can, for example, “step” into a library component developed in C# from an ASP.NET application developed in Visual Basic. This is considerably more convenient than today’s setup, whereby you might be working with numerous develop environments: Visual InterDev for ASP code, the Visual Basic environment for VB components, and Visual Studio for C++ COM components.


In addition to making web applications easier to develop, ASP.NET makes it easier to deploy and maintain them. Application configuration settings are stored in easily accessible XML files, as opposed to the IIS proprietary metabase that housed such information in traditional ASP. As you will see in Chapter 7, the ASP.NET engine is considerably more robust and manageable than its ASP predecessor, which allows one to store client session information in SQL Server, for example. The engine can also be “recycled” (restarted) when its memory usage reaches a prescribed limit, which offers greater reliability.


The impact of ASP.NET on your development efforts largely depends upon your background.

If you are an ASP developer, you will be happy to learn that ASP.NET abstracts, to a large degree, the idiosyncrasies of the web with which you have had to familiarize yourself. Rather than worrying about concepts such as HTML tags, POST, GET, and Querystrings, you can concentrate on writing application code. This is not to say that ASP.NET renders your existing skill set obsolete; it simply takes care of many redundant details that you must manually code in ASP. You always have the option of overriding ASP.NET’s automation of these details whenever you wish. ASP developers will especially welcome the strongly typed languages that ASP.NET supports, as well as VS.NET’s intuitive design environment, which allows one to debug applications using features such as breakpoints and instant watches.

If you program primarily in Visual Basic, you can apply the design methodology you’ve used for years directly in ASP.NET—by dragging and dropping controls onto a form (a Web Form in ASP.NET) and then writing the logic behind them. ASP.NET exposes an event paradigm that Visual Basic developers will instantly recognize. For example, when a web page loads, it automatically invokes the Page_Load() method, similar to the Form_Load() method in Visual Basic. With ASP.NET, it is entirely possible to develop a web application without any knowledge of HTTP, HTML, or web design. Simply create your application in VS.NET and it will be rendered in a browser by the ASP.NET runtime.

If you come from the world of C++ or Java you will probably develop applications using either C# or J#. As we will see in this chapter’s Core Concepts section, C# (pronounced “C-sharp”) is similar to C++, whereas J# (J-sharp) is Microsoft’s conversion of the Java language to the .NET world. If you are familiar with JavaServer Pages (JSP), you will find that in many respects ASP.NET is more like JSP than traditional ASP. For example, both JSP and ASP.NET use strongly typed and compiled languages. JSP uses Java and compiled Servlets (server-side applets). Architecturally, you can think of a Servlet container as the equivalent of the ASP.NET runtime. Both the Servlet container and the .NET runtime interpret the compiled code and provide the necessary services for connecting to the Web Server.

Like JSP, both ASP and ASP.NET have built-in objects (Request, Response, Session, etc.) and similar syntax for web tasks (redirect, forward, etc.). However, it is not necessary to use these built-in objects in ASP.NET; you can simply write web-based applications as you would write a desktop application. More on this in the upcoming example.

If you are responsible for infrastructure and deployment in your organization, then you will be happy to learn that existing ASP applications will not be affected when one installs ASP.NET—applications from both frameworks will run side by side. Furthermore, ASP.NET offers numerous options that increase application reliability, fine-tune performance, and simplify maintenance. One of the biggest headaches with traditional ASP was the necessity to shut down the entire Web Server whenever you wanted to update a component being used by an ASP application. In Chapter 7, we will see that .NET components do not suffer from this annoying limitation.

Book’s Contents

In this chapter we will examine the fundamentals of ASP.NET and the .NET Framework upon which ASP.NET is built. The Core Concepts section of this chapter lays the groundwork for the more advanced topics in later chapters. This chapter concludes with a simple example that contrasts application development in ASP with ASP.NET.

Chapter 2 provides installation instructions for ASP.NET. Because .NET was still in Release Candidate revisions at the time of this writing, these instructions may be out of date and readers are encouraged to consult the online instructions at aAS020001.

In Chapter 3, we examine the .NET Framework, emphasizing the portions that are relevant to ASP.NET. The .NET Framework is the foundation for all .NET applications, languages, and services, ranging from VB.NET to ASP.NET.

Chapter 4 discusses ASP.NET’s new design paradigm, which will be unfamiliar to many developers. In this chapter we examine the framework’s web form paradigm and the VS.NET environment that allows you to employ it.

One of the most significant differences between ASP and ASP.NET lies in the area of Windows Forms and Web Forms. Using VS.NET, you can build complicated forms that will automatically generate HTML code appropriate for your target browser. As a developer, you simply have to drag and drop controls. You don’t have to worry about writing HTML or checking for compatibility issues. In Chapter 5, we will examine several of the Web Controls and Web Form components that are available in ASP.NET

As discussed in Chapter 6, one of the advantages of using the .NET Framework is that you can leverage features such as cross-language debugging and tracing. Not only can you debug your ASP.NET applications, you can seamlessly maneuver into code developed in C#, J#, VB.NET, or any other .NET language. You can also use the .NET engine to cache the various components of your web page, greatly enhancing performance.

Once you have built your ASP.NET application, the next challenge is to deploy it onto your server and configure it properly. In Chapter 7, we examine many of the deployment issues and configuration strategies. In particular, we will look at building and deploying assemblies and configuring IIS for various conditions.

Chapter 8 discusses security issues. In any significant web application, security will always be a primary concern. With ASP.NET, you have to consider two different aspects of security. First, you must know how to configure the security settings in IIS. Next, you can refine your security settings through the various methods built into ASP.NET. By combining these two independent security systems, you can create complex, fine-grained, and robust security polices to protect your web application.

ASP.NET would not be as exciting if you were forced to rewrite your entire existing code base on the .NET platform. Although Chapter 9 does cover migration from ASP (and other HTML systems), it also covers the mechanisms for executing and working with legacy code, such as COM objects and Enterprise Services.

Core Concepts

One of the fundamental challenges in writing a succinct yet thorough explanation of a technology is the varying knowledge level of the readership. To this end, this Core Concepts section defines many terms you may or may not be familiar with. This section is broken into three parts: the .NET Framework, which examines the architectural foundation for ASP.NET; Web Concepts, which illustrates the required technologies to host web applications on the Windows Operating System; and Windows Concepts, which explains some of the Windows technologies that you may be currently leveraging. If you want a more thorough introduction to .NET or VB.NET, see CodeNotes for .NET Component Developers and CodeNotes for VB.NET.

Read More

Customer Reviews

Average Review:

Write a Review

and post it to your social network


Most Helpful Customer Reviews

See all customer reviews >