Introduction to ASP.NET 2.0



With the release of ASP.NET 1.0, Microsoft revolutionized Web application development by pro-
viding a rich set of features aimed at increasing developer productivity. Now with ASP.NET 2.0,
Microsoft increased the bar to a much higher level by providing excellent features out-of-the-box
that are not only geared towards increasing the productivity of the developers but also simplifying
the administration and management of ASP.NET 2.0 applications. These new features combined
with the increased speed and performance of ASP.NET 2.0, arm the developers with a powerful
platform that can make a significant impact in the way Web applications are developed, deployed,
and maintained.
This chapter takes a quick tour of the new ASP.NET 2.0 features. Specifically, this chapter discusses
the features of this new improved platform that will help you in designing, developing, and
deploying enterprise class Web applications.
ASP.NET 2.0 Features
When Microsoft started designing the feature-set of ASP.NET 2.0, they had the following three
core themes in mind:
  Developer Productivity
  Administration and Management
  Speed and Performance
The next few sections examine the features of ASP.NET 2.0 based on these categories.
Developer Productivity
One of the goals of ASP.NET 2.0 is to enable developers to easily and quickly build feature-rich
Web applications. To accomplish this, Microsoft has looked at the existing ASP.NET 1.x applica-
tions to identify the common features, patterns, and code that developers build over and over
today. After they have identified those features, they have componentized those features and included
them as built-in functionality of ASP.NET. With ASP.NET 2.0, the ASP.NET team has a goal of reducing
the number of lines of code required for an application by a whopping 70 percent. To this end, Microsoft
has introduced a collective arsenal of new features that are now available to developers in ASP.NET 2.0.
Using these features, you can spend your time building richer, more fully featured applications by
leveraging the new controls and infrastructure services built into the core platform as opposed to writing
a lot of infrastructure code as is the case with ASP.NET 1.x. For example, ASP.NET 2.0 now includes
built-in support for membership (user name/password credential storage) and role management services
out of the box. The new personalization service provides for quick storage/retrieval of user settings and
preferences, enabling rich customization with minimal code. With ASP.NET 2.0, Microsoft has introduced
a new concept known as Master Pages that now enable flexible page UI inheritance across sites. The new
site navigation system enables developers to quickly build link structures consistently across a site. Site
counters enable rich logging and instrumentation of client browser access patterns. Themes enable flexible
UI skinning of controls and pages. And the new ASP.NET Web Part framework enables rich portal-style
layout and end user customization features that would require tens of thousands of lines of code to write
today. Along with all these features, ASP.NET 2.0 also brings with it 45 new server controls that enable
powerful declarative support for data access, login security, wizard navigation, image generation, menus,
treeviews, portals, and more. The next few sections provide you with a glimpse of these features.
Master Pages
ASP.NET 2.0 introduces a new concept known as Master Pages, in which a common base master file
contains the common look and feel and standard behavior for all the pages in your application. After the
common content is available in the Master Page, the content pages (child pages) can inherit content from
the Master Pages apart from adding their content to the final output. To allow the content page to add its
own content, you add placeholders (known as ContentPlaceHolder control) in the Master Page that
will be utilized by the content pages (or child pages) to add their custom content. When users request
the content pages, the output of the content pages are merged with the output of the Master Page, resulting
in an output that combines the layout of the Master Page with the output of the content page.
In ASP.NET 1.x, you could achieve similar effects by creating user controls that abstract
the common look and behavior of all the pages in the application and then declaring
user control in each and every page. Even though this approach was useful, it required
a lot of cut and paste of code across all the pages in a Web application. Master Pages
take this approach of reusable user controls to the next level by providing a much
cleaner approach to reusing common look and feel across all the pages.
Master Pages are saved with the file extension .master. Apart from containing all the contents that are
required for defining the standard look and feel of the application, the master pages also contain all the
top-level HTML elements for a page, such as <html>, <head>, and <form>. As mentioned earlier in this
chapter, the Master Pages also contain one or more content placeholders that are used to define regions
that will be rendered through the content pages. Now that you have had a general understanding of
Master Pages, let us look at an example. First, create a Master Page named BasePage.master and add the
code shown in Listing 2-1.