Freigeben über


What's New in ASP.NET

The Microsoft .NET Framework version 2.0 includes significant enhancements to ASP.NET in virtually all areas. ASP.NET has been improved to provide out-of-the-box support for the most common Web application situations. You will find that you can get Web sites and pages up and running more easily and with less code than ever before. At the same time, you can add custom features to ASP.NET to accommodate your own requirements.

Specific areas in which ASP.NET has been improved are:

  • Productivity. You can easily and quickly create ASP.NET Web pages and applications using new ASP.NET server controls and existing controls with new features. New areas such as membership, personalization, and themes provide system-level functionality that would normally require extensive developer coding. Core development scenarios, particularly data, have been addressed by new data controls, no-code binding, and smart data-display controls.

  • Flexibility and extensibility. Many ASP.NET features are extensible so that you can easily incorporate custom features into applications. The ASP.NET provider model, for example, provides pluggable support for different data sources.

  • Performance. Features such as precompilation, configurable caching, and SQL cache invalidation allow you to optimize the performance of your Web applications.

  • Security. It is now easier than ever to add authentication and authorization to your Web applications.

  • Hosting. ASP.NET includes new features that make it easier to manage a hosting environment and create more opportunities for hosters to add value.

  • Completeness. New and existing features work in concert to allow you to create end-to-end scenarios that address real-world Web development challenges.

The following sections of this topic describe changes made in different areas of ASP.NET:

  • Web Site Management

  • Page Design

  • Controls

  • Data

  • Security

Web Site Management

Web site configuration is improved to include many more settings. You can easily manage application settings using the Web Site Administration Tool, which provides a wizard-like interface for setting up and maintaining your applications. The Web Site Administration Tool is particularly useful for managing remote sites (for example, sites that are hosted by an ASP.NET-compatible ISP).

If you host sites for others, you can use a new ASP.NET Microsoft Management Console (MMC) plug-in or an administrative API to manage sites and monitor their health. You can add value to your hosting site by offering controls or services that you can selectively enable or disable.

New Administration Features and Tools

ASP.NET includes features to make Web site management easier for both Web site developers and for administrators. Configuration files include a richer set of elements that give site developers control over new features and finer control over existing ones. A new configuration API makes it possible to control configuration programmatically. New tools provide a GUI interface for configuring applications — the new Web Site Administration Tool makes it easy for Web site developers to manage their own sites using a Web-based interface (both locally and remotely), and an ASP.NET-specific MMC snap-in allows site administrators to manage complex configuration scenarios using a standard Windows server-based tool.

Reserved Folders for Special Functionality

Web sites can include an App_Code folder into which site developers can put source code that is then compiled automatically as part of the Web site, making it unnecessary to compile components or controls before using them in a site. An App_Data folder is reserved for databases (for example, SQL Server Express Edition .mdf files). Special folders for resources contain XML-based files containing strings and other resources for localization, which are dynamically compiled into assemblies at runtime. For details, see ASP.NET Web Site Layout.

Precompiling Web Sites for Error Checking and Deployment

You can now precompile your Web site, which allows you to enhance performance by avoiding the overhead of dynamic compilation and allows you to catch compile-time errors. You can also precompile a site for deployment, producing a version of the site that you can easily copy to or install on a production server. Precompiling for deployment strips source code, which helps you protect your intellectual property. For details, see ASP.NET Web Site Precompilation Overview.

You can add site navigation to your Web sites by defining a site map (typically an XML file). You can then use new navigation controls such as the TreeView and SiteMapPath controls that can automatically create a menu or tree view of pages, or that can display a navigation path (also known as a breadcrumb) showing the current page hierarchy. For details, see ASP.NET Site Navigation Overview.

Page Design

New features of ASP.NET help you easily create pages that are more consistent and can offer a richer experience to users.

Consistent Layout using Master Pages

You can use master pages to create a consistent page layout for your Web site or for a group of related pages. On the master page, you define a common look; you can then create individual content pages that provide the dynamic content that is displayed using the master page as a template. For details, see ASP.NET Master Pages Overview.

Themes for Consistent Appearance

Themes allow you to create a consistent look for your site. A theme contains a collection of control skins that define property settings (such as background color and font), CSS style settings, and images to specify the appearance of a control. For details, see ASP.NET Themes and Skins Overview.

New Code-Behind Model for Pages

ASP.NET continues to support the single-file model from the previous version of ASP.NET and now includes a new code-behind model. The new model allows you to use a new .NET Framework feature, partial classes, to create a code file with just the code in it that you need, such as event handlers. The end result is a clean separation of the markup from the code in a page, and a robust model for managing a page’s code. For more information, see the ASP.NET Page Class Overview.

User-Customizable Web Pages

With Web parts, you can create modularized Web pages that users can customize extensively. A Web part incorporates a discrete piece of functionality, such as a weather report, a stock ticker, or a window for reading news. ASP.NET allows you to create your own Web parts. You can then create Web pages that include a selection of Web parts. Using the Web parts architecture, you can allow users to customize individual Web parts (for example, by typing in a ZIP code to display local information) and change the layout of Web parts. You can also allow users to add and remove Web parts, thereby giving users the ultimate flexibility in using your site. For details, see ASP.NET Web Parts in Visual Studio.

User-Specific Values

You can provide users with a custom experience in your Web site by defining and using profile properties, which you can use to track user information (address, city), preferences (color scheme, list of stocks to follow), or any custom information required by your application (shopping cart). Once you have defined profile properties, ASP.NET automatically associates individual instances of the profile properties with each user, and you can use code to set or get the values. ASP.NET persists property values in a data store (which you can configure), and the next time a user visits your site, ASP.NET automatically retrieves the profile property value for that user. For details, see ASP.NET Profile Properties Overview.

New Caching Features

Enhancements to caching help you increase the performance of your site and manage the cache more precisely. You can manage caching at the Web site level using Web.config settings, rather than managing it at the page level. You can now invalidate cache contents programmatically. If you are using SQL Server 7.0 or later, you can set up a cache dependency based on a SQL Server database table so that when the table changes, the cache entry dependent on it is made invalid. For more information, see the ASP.NET Caching Overview.

Enhanced Client-Side Functionality

ASP.NET pages make it easier to add client-side functionality to pages to enhance the run-time experience for users. You can more easily bind client-side event handlers to controls and add better support for accelerator keys. For multi-page forms, you can use the new Wizard control, or you can take advantage of the new cross-page-posting facility in Web pages.

Controls

ASP.NET features many improvements to Web server controls, including both enhancements to existing controls and a selection of new controls.

General Control Improvements

A major area of enhancement in ASP.NET 2.0 is in the controls you use to create ASP.NET Web pages. General improvements to controls include:

  • By default, controls now generate markup that is compatible with the XHMTL 1.1. standard.

  • All controls support adaptive rendering, and can emit markup that is appropriate for the requesting browser.

  • All data controls can use either the new data-binding model with data source controls, or can continue to use the model used in earlier versions of ASP.NET.

  • All controls support themes and skins so that you can customize their appearance using an ASP.NET theme.

  • You can use device filtering with many control properties, specifying different property values for different devices. When the control is rendered, the appropriate property value is set based on the requesting browser.

  • Validator controls can now be grouped, which allows you to selectively enable validation for some controls.

  • Improvements to individual controls such as the Label control, ListBox control, and others to add functionality often requested by developers.

New Controls

ASP.NET offers a greater selection of controls to help you create fully featured Web pages much more quickly. You can now take advantage of the following controls:

  • Data. The GridView control is a highly capable data grid that can display and edit data, page, and sort, all without code. The TreeView control displays XML data and includes many options to customize both its appearance and behavior. To simplify data binding, you can use the new data source controls, described in more detail below under Data.

  • Navigation. You can add navigation paths (also known as breadcrumbs) to pages with the SiteMapPath control and display a site map using the TreeView control.

  • Security. You can authenticate users with a suite of login controls that allow you to get and validate user credentials, display custom output for logged-in users, and more. For more information, see Security.

  • Web Parts. A new set of Web Part controls allow you to create portal pages that users can personalize at run time. For example, you can create a Web Part that allows a user to enter a custom value such as a postal code and get localized weather reports.

  • Client behavior. New controls provide ASP.NET server control functionality for tasks that previously were handled only by HTML elements. These include the FileUpload control, ImageMap control, and the HiddenField control. The new Wizard control allow you to create a page with multiple panels that step the user through multi-part forms.

In addition, existing ASP.NET controls have been enhanced with new features. All controls now support the new data-binding model, themes, and personalization. You can also use all controls to create pages for devices; controls now automatically support adaptive rendering and device filtering. For more information, see Device Support.

Data

ASP.NET includes substantially improved support for working with data in your Web applications.

Data Source Controls

For binding data to controls on Web pages, you can now use data source controls, which encapsulate connections, query commands, and parameters into a single control. ASP.NET includes data source controls that work with a variety of back-end data sources, including Microsoft SQL Server, Microsoft Access, XML files, Web services, FrontPage site maps, and business objects that return data sets. All data source controls support the same basic object model, giving you a consistent way to work with data regardless of its source.

Data source controls can automatically fetch data and manage it when the page runs. You no longer need to write code to execute commands and manage datasets for common data scenarios. However, if your application requires it, you still have access to the lower-level data functions exposed by ADO.NET.

To pass parameters to data source controls, you can configure the controls to draw parameters values from other controls, Session state, query strings, or cookies; in addition, you can set parameter values programmatically.

Middle-Tier Data Access

By using the new ObjectDataSource control, you can easily add data access to a page that is based on a middle-tier business object. The ObjectDataSource exposes the same binding interface to controls on the page, but instead of performing direct database access, it invokes methods on a component that you specify.

Data Display Controls

ASP.NET also includes enhanced support for displaying and updating data with controls on Web pages. All controls can now use data source controls as data source instead of working directly against a dataset or other store. You can also take advantage of the following new controls that are specifically built to make data access easier:

  • The GridView , DetailsView , FormView controls to display and edit data. (The GridView control supersedes the DataGrid control from previous versions of ASP.NET.)

  • The TreeView control to display hierarchical information from XML files, sitemap files, and relational data sources.

  • The SiteMapPath and Menu controls to provide data-bound support for navigation.

XML Support

You can use XML data in a variety of ways in ASP.NET. An XML data source control exposes XML data to be used either as hierarchical or tabular data. You can bind a TreeView control to XML data to provide a hierarchical view for users, or you can bind a list control such as the GridView control to display XML in a traditional way.

Connection String Storage

To enhance Web site security, you can store connection strings in a dedicated section of the configuration file.

Security

New ASP.NET features provide built-in support for authenticating and authorizing users. ASP.NET membership manages authentication, providing facilities for validating user credentials and helping users manage their passwords.

The membership service provides APIs that you can call programmatically to create new users, validate credentials, and get user information. To simplify authentication even more, you can use the new login controls, which work with the ASP.NET membership to perform a variety of tasks, often with no extra code required. The Login control prompts users for credentials and validates them. The PasswordRecovery control provides various options for helping users either change or remember their password. You can display user information with the LoginName control, and present a Login or Logout button using the LoginStatus control. The LoginView control allows you to mark content in a page that is visible only to authenticated users.

For more information, see Introduction to Membership.

ASP.NET role management helps you manage authorization, providing high-level ways for you to define and check roles for users. For details, see Understanding Role Management.

Both the membership and role management systems use the new ASP.NET provider model, which separates the functionality of the systems from the data store that supports them. For example, membership allows you to store user information in Microsoft SQL Server or Microsoft Access. If these default options are not suitable for your requirements, you can create your own provider that accepts calls from membership and then fulfills them using your custom data logic.

See Also

Concepts

ASP.NET Overview

Other Resources

ASP.NET 2.0 QuickStart Tutorials