Analysis on the personalization features of ASP. NET basic tutorials

Source: Internet
Author: User

ASP. NET personalization is a key part of most Web applications. TechRepublic and Amazon are typical examples. They can remember certain characteristics of users. Applying ASP. NET 1.x to implement this function requires some additional work and the Session object to be used. ASP. NET2.0 simplifies the personalization process.

ASP. NET personalized files in basic ASP. NET tutorials

The ASP. NET 2.0 Profile system allows you to easily store user information. Define attributes related to each user and store them in their profile. Personal File data can be easily accessed by a program. Like other stored files, it must be stored, and personalized files use SQL Server by default.

The Profile system is based on the provider model. A special Profile provider is responsible for serializing and deserializing attribute values to a data warehouse .. NET Framework uses a SqlProfileProvider class by default, which uses an SQL Server database table to store data.

System Configuration of ASP. NET basic tutorial

Before using the personalized file feature of ASP. NET 2.0, you must correctly configure the Web server to support this feature. By default, the personalized file feature uses an SQL Server terminal, but you can also create your own provider. This article mainly discusses the standard SQL Server Terminal, which uses the default SqlProfileProvider class.

SQL Server supports versions 7.0, 2000, and 2005. To configure a system that supports SQL Server, you must first configure the database Server, and finally the ASP. NET platform.

. NET Framework 2.0 contains tools for correctly configuring the ASP. NET environment. If you use SQL Server 2005 Lite version and Visual Studio, you do not have to configure them. If no application is available, the first step is to register an SQL Server connection. Use the command line tool aspnet_regsql.exe installed with. NET Frameworkto complete this operation. On my machine, the path of this tool is:

The following is a reference clip:

 
 
  1. C:WindowsMicrosoft.NETv2.0.50727aspnet_regsql.exe  

This tool contains a large number of options. You can use the command line option (-?) Read more. In the development system, use the existing SQL Server 2000. The following command configures the environment by creating the necessary database on the specified server.

The following is a reference clip:

 
 
  1. Aspnet_regsql.exe –A p –E –S database_server_name  

Command line switch E tells the system to use the current user certificate for verification. The S switch allows you to specify the name of the database server. Switch A to indicate the option to be added, and p to indicate the support for personalized files. Run this command to create an SQL Server database. The default name of the database is aspnetdb, but you can also use the command line switch d to undo it. The switch d allows you to specify an existing database.

Now you have created an SQL Server environment. Next, you should configure ASP. NET 2.0 to use connections and personalized files. Go to the IIS Management page, view the properties of the ISS website (Web Sites), and select the ASP. NET tag to activate the ASP. NET environment attributes. Select the Edit Configuration button on the ASP. NET label. The Authentication tag contains a Role area in which Role Management is activated (which should be viewed ). The default SQL Server (LocalSqlServer) connection string is specified in the General label. The development environment uses the following connection string:

The following is a reference clip:

 
 
  1. data source= database_server_name;Integrated Security=SSPI;   
  2. Initial Catalog=aspnetdb;User Instance=false  

Save these changes in the ASP. NET environment and connect them to the configured SQL Server instance. After the platform is configured, you can start execution.

Definition element of ASP. NET basic tutorial

Data elements used in personalized files are created and saved in the web. config file (that is, the stored data value is defined in that file ). The actual value (for different users) is saved in a terminal data warehouse. You can specify the name, data type, and data serialization method of each attribute.

The data type of the property is the same as the valid standard data type in. NET. Serialization options generally depend on the data type to be stored, but there are four serialization options:

ProviderSpecific: by default, the Profile provider determines how to serialize attribute values.

String: the property value is converted into a string.

Xml: convert the property value to XML format.

Binary: convert the property value to binary.

The individual file elements defined in the attribute element are contained in the individual file elements, which are located in the system. web part of the web. config file. The web. config in list A contains A piece of personalized files supported by the personal files before the application. It uses two personalized file items-FirstName and LastName-to save string values and allow anonymous users.

Both anonymous users and authenticated users can apply personalized file features. The preceding web. config file uses the allowAnonymous attribute of the Personal File element, and activates anonymous support for the application (anonymousIdentification element) to specify anonymous support.

Use Code

After the environment is correctly configured, you can easily apply personal file elements in. NET code. Simple C # code in list B uses the Personal File element to store and display data values. It uses the Profile class contained in the System. Web namespace. The Code contains the ASP. NET file after the code separation file.

List C contains the code separation (codebehind) of the custom code ). The first button stores the values of each text field in the Personal File domain. The second button restores values from the Personal File domain and fills the text domain with these values.

ASP. NET: Simplified ASP. NET personalization

Personalization is only one of many new features of ASP. NET 2.0. After several configuration steps, you can use the standard web. config file and Profile class encoding to easily add personalized features to your application.

  1. Introduction to ASP. net mvc Framework
  2. Introduction to MvcAjaxPanel in ASP. NET MVC
  3. ASP. net mvc Framework to save UpdatePanel
  4. Use ASP. net mvc source code to find a solution
  5. ASP. NET code hidden files

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.