The upgrade of ASP.NET technology from version 1.0 to 1.1 has not changed much. However, upgrading from ASP.NET 1.x to 2.0 is not an easy task. ASP.NET 2.0 technology adds a large number of convenient and practical new features. ASP.NET 2.0 mainly provides technical features in three aspects: controls, page frameworks, services, and APIs.
Controls
In the ASP.NET 1.x era, developers complained a lot due to the limited number of built-in server controls and narrow functional coverage. In order to eliminate this technical weakness, ASP.NET 2.0 has made breakthrough improvements. In ASP.NET 2.0, dozens of new server controls are added. According to the functional characteristics of controls, they can be divided into: data controls (including data source controls and data binding controls), login series controls, Web parts, site navigation controls and other controls. These server controls play an important role in improving work efficiency and reducing development costs.
Page framework
In terms of page framework, ASP.NET 2.0 has also made major improvements, which are mainly reflected in the following four technical features: master page, theme and skin, compilation mechanism and localization. The master page feature is widely used in large-scale Web sites. It can replace the frame page function to a certain extent, thereby quickly establishing a page with a unified layout and appearance, and effectively reducing the work intensity of maintenance personnel. Themes and skins are a new feature of ASP.NET 2.0. You can use this feature to set the appearance style of a type of server control at one time. The look can be easily applied to a single page, an entire web application, or even an entire server. When it comes to application compilation, ASP.NET 2.0 offers several alternatives, broadening the compilation choices that developers can choose based on their specific needs. In addition, ASP.NET 2.0 has also made some improvements in localization.
The new features included in the
services and APIs
section account for a large proportion in ASP.NET 2.0, mainly including membership management, role management, user configuration, data caching, configuration and management tools, etc.Using these functions, you can quickly implement tasks such as user and role management, personalized user configuration, data caching, and application visual configuration. Take the membership and role management functions as an example. In the ASP.NET 1. With a simple method, you can easily implement member and role management functions.
1. Add new server controls
In the ASP.NET 1.x era, many developers criticized the built-in server controls. The main point is that the number of controls provided by ASP.NET 1.x is too small to meet the growing development needs and to develop applications faster and better. In order to make up for the shortcomings of ASP.NET 1.x, ASP.NET 2.0 adds dozens of server controls. According to the control function, it can be divided into site navigation controls, data controls (including data source controls and data binding controls), login series controls, Web parts and other server controls, etc. Proficient use of these server controls is of great significance to improving work efficiency and reducing development costs.
1. Site navigation control
During the ASP.NET 1.x period, Microsoft released a set of IE Web Control controls (non-built-in controls), including a TreeView control that implements a tree structure, which is a typical site navigation control. In ASP.NET 2.0, not only the original TreeView is included and extended, but two other controls are also added.
Site navigation controls are mainly used to implement site page navigation functions. Site navigation controls include SiteMapPath, Menu and TreeView controls. The SiteMapPath control can accurately locate the location of the entire Web site where the current page is based on the site navigation information. At the same time, it uses a hierarchical representation method to display the location information as ordered static text or hyperlinks. In addition, you can also customize the appearance of location information and implement data binding and other functions by adjusting related attributes. The Menu control builds menus similar to Windows applications. This control can not only be integrated with a variety of data source controls, but also support custom appearance, event handling and other functions. The TreeView control is mainly used to display a tree structure, which is similar to the tree in Windows Explorer. At the same time, the control also supports data binding, custom appearance and other functions.
2. Data control
The data controls of ASP.NET 2.0 can be subdivided into two categories: one is the data source control, and the other is the data binding control. Data source controls include SqlDataSource, AccessDataSource, XmlDataSource, SiteMapDataSource and ObjectDataSource. These controls mainly implement functions of connecting different data sources, data retrieval and modification, such as query, sorting, paging, filtering, updating, deleting and inserting, etc. Data binding controls mainly include GridView, DetailsView, FormView, etc. These controls can cooperate with the data source control to display the obtained data on the page in different forms. Because data source controls and data-bound controls support good visual design-time capabilities, when using Visual Studio 2005 to implement data access, you don't even need to write any code to complete the task.
3. Login series controls. Many Web sites provide user login verification and related functions. Common functions include user login, creating new users, etc. Generally speaking, the basic methods to implement these functions are relatively similar. However, due to differences in the level of developers, some unnecessary loopholes and errors may occur. In order to solve this problem, ASP.NET 2.0 integrates the implementation related to login verification into the login series controls. These controls include: Login, LoginName, LoginView, LoginStatus, PasswordRecovery, ChangePassword, and CreateUserWizard. Use these controls to easily implement login verification, create new users, display login status, display login user name, update and reset passwords, etc. For flexibility, the login series controls not only provide a large number of member objects, but also support custom template functions (supported by some controls). In addition, the login series controls also strengthen security controls. For example, by default, the login series controls work in plain text over HTTP. If your application is security-focused, you can use HTTPS with SSL encryption.
The Login control is used to implement user login verification, and the CreateUserWizard control is used to create new users. Perhaps readers will follow the thinking before ASP.NET 2.0 and think that to implement the above two applications, you need to add multiple text boxes, buttons and other elements, and design and implement databases, data access logic, etc. In fact, it is very simple to use the Login and CreateUserWizard controls to implement the above application. It is so simple that there is no need to write any code or build a self-made database. You only need to add and set controls.
4. web parts
Web parts are a new feature of ASP.NET 2.0. If you have ever developed and used SharePoint, you should be familiar with Web Parts. The Web part function of ASP.NET 2.0 includes multiple server controls, such as WebPartManager that implements WebPart control management and control, EditorZone and EditorPart series controls that implement editing WebPart controls, CatalogZone and CatalogPart series controls that implement catalog management, and WebPart communication that implements WebPart communication. ConnectionZone control, etc. They can be used to create highly flexible and personalized Web sites.
5. Other server controls In addition to the 4 types of controls introduced above, ASP.NET 2.0 adds other server controls. These controls include BulletedList, HiddenField, FileUpload, ImageMap, MultiView (View), and Wizard.
2. Master page
Every site should have a consistent style and layout. Different technological eras have provided different solutions. For example, in the ASP technology period, the #include command was used, and in the ASP.NET 1.x period, user controls were mainly used. In the ASP.NET 2.0 technology period, you can use the technical feature of building a page layout framework—the master page.
A master page is a file with a .master extension, and its code content and structure are similar to ordinary .aspx files. Note that the code includes one or more ContentPlaceHolder controls. When creating a master page, the public parts of the page need to be stored in the master page, such as the common header and footer of the page, while the non-public parts of the page are placed using the ContentPlaceHolder control. Although the extension of the content page file is .aspx, the code content and structure are far from the ordinary .aspx file code. The code is divided into two parts: the code header declares one or more Content controls. Developers need to bind the master page in the code header of the content page, and at the same time, set the non-public part of the page between the Content control tags. At runtime, the user cannot directly request the master page, but can only request access to the content page. At this time, the master page and content page will be merged to generate a result page, which contains the running results of the public and non-public parts of the page.
3. Theme and skin
Before you come into contact with themes and skins, you may have been accustomed to using cascading style sheets (CSS) to set the appearance and style of elements such as pages and controls. Although CSS is also applicable in ASP.NET 1.x development, if you encounter some complex controls, such as Calendar and GridView, setting CSS will become more difficult. If the server control can be set entirely based on the appearance and style properties of the control itself, not just the elements specified in CSS, then the entire implementation process will become simpler. The theme and skin functions in ASP.NET 2.0 can provide such convenience.
The so-called "theme" refers to a collection of page and control appearance property settings. A theme consists of a set of files, which may include skin files, CSS files, images and other resources. These files must be stored in the App_Themes folder. Skin files are the core content of a theme. This file has a .skin extension and contains various property settings for various server controls. Using themes, you can not only define the appearance of pages and controls, but also quickly and consistently apply the defined appearance to all web applications, all pages of a single web application, or a single web page. Additionally, themes can be loaded dynamically based on application needs.
4. Personalized user configuration
Storing and accessing user configuration data has always been a hot topic for developers. In the ASP.NET 1.x era, this function was mainly implemented through objects such as Session and Application or using database storage methods. Both methods have their own insurmountable shortcomings. For example, using the former is prone to data loss, while using the latter is more cumbersome. For example, you need to design the code to implement the database and access the data yourself. In order to solve the above problems, ASP.NET 2.0 adds a new personalized user configuration function.
The personalized user configuration function is mainly used to store individual user configuration data, which can be simple data types, complex data types, or even custom objects. At the same time, a single user can be either an anonymous user or a registered user. By default, all user configuration data is stored in a SQL Server database, and there is no need to create and maintain the database yourself. These tasks are automatically completed by ASP.NET 2.0. The personalized user configuration feature also supports a variety of strongly typed APIs accessible from anywhere in the application to easily store, display and manage user configuration information. Using the Personalized User Configuration feature is easy. First, define the configuration information name, data type, etc. in the Web.config file, and then call the strongly typed API related to the user configuration function. For example, Profile implements applications such as storage, access, and management of user configuration information.
5. Membership and role management
The backend management of most sites almost includes user member and role management functions, such as creating, modifying, and deleting users and roles, setting roles for users, and managing users in roles. When using ASP.NET version 1.x, the main method to implement these functions is to first design and create member library tables, role library tables, etc., and then write code to implement specific functions. Implementing all functions may take a lot of time and effort, and the process is cumbersome and error-prone. However, this problem can be solved well using the new membership and role management features of ASP.NET 2.0.
The core of the membership and role management function is to use automatically generated database tables, multiple APIs that implement management functions, and membership and role management providers to implement a modular and automated membership and role management model. Specifically, it includes creating and managing user and role information, managing user and role information in multiple data sources, verifying user credentials for accessing applications, supporting the use of cookies to cache role information, implementing role management and membership management, etc. Integration of functions.
6. Configuration and management tools
In order to realize application configuration and management quickly and conveniently, ASP.NET 2.0 provides two built-in visual tools: one is the ASP.NET MMC management unit and the other is the Web website management tool.
If Internet Information Services (IIS) and .NET Framework 2.0 are installed on your computer, you can use the ASP.NET MMC snap-in by opening IIS. Use this tool to comprehensively configure connection strings, application configuration, custom errors, authorization, authentication, public compilation, pages and runtime, globalization and identity, application state, location, and more for a given application. All setting results will be displayed in the application Web.config file. From this perspective, the ASP.NET MMC snap-in is a graphical tool for editing Web.config files.
If you use Visual Studio 2005 to create an ASP.NET 2.0 application, you can call the Web site management tool. Unlike the ASP.NET MMC management tool, the Web site management tool is a Web application, not a Windows application. Web site management tools provide various settings for specified Web applications such as security, application configuration, and providers. For example, create and manage user and role information, set SMTP parameters, set various providers, etc.