Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What are the characteristics of ASP.NET personalization

2025-04-07 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

This article mainly explains "what are the personalized characteristics of ASP.NET". The content of the explanation is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn "what are the personalized characteristics of ASP.NET".

The ASP.NET personalization part of the ASP.NET fundamentals tutorial is a key part of most Web applications. TechRepublic and Amazon are typical examples, which can remember some of the characteristics of the user. Implementing this with ASP.NET 1.x requires some extra work and uses Session objects, while the ASP.NET2.0 version simplifies the personalization process.

ASP.NET personalized files for ASP.NET basic tutorials

The ASP.NET 2.0 Profile system allows you to easily store user-related information. Define attributes related to each user and store it in their personality file. Personality file data can be easily accessed by program. Like other saved files, it must be stored, and personality files use SQL Server by default.

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

System configuration of ASP.NET basic tutorial

Before using the personality file feature of ASP.NET 2.0, the Web server must be properly configured to support this feature. By default, the personality file feature uses a SQL Server terminal, but you can also set up your own provider. This article focuses on 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 should first configure the database server, which is the ASP.NET platform.

The .NET Framework 2.0 includes tools for correctly configuring the ASP.NET environment. If you use SQL Server 2005 Lite and Visual Studio, you don't have to configure it. If the above program is not applied, the * step is to register a SQL Server connection. You can do this by using the command line tool Aspnet_regsql.exe installed with the. NET Framework On my machine, the path to this tool is:

The following is a reference clip:

C:WindowsMicrosoft.NETv2.0.50727aspnet_regsql.exe

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

The following is a reference clip:

Aspnet_regsql.exe-A p-E-S database_server_name

The command line switch E tells the system to authenticate with the current user certificate. Switch S allows you to specify a database server name. Switch An indicates which option to add, followed by p to add personality file support. Execute this command to create a SQL Server database. The default name of the database is aspnetdb, but it can also be undone with the command line switch d, which allows you to specify an existing database.

Now that you have established a SQL Server environment, you should configure ASP.NET 2.0 to take advantage of connections and personality files. Go to the IIS management interface, view the ISS website (Web Sites) properties, and select the ASP.NET tag to activate the ASP.NET environment properties. Select the Edit configuration (Edit Configuration) button on the ASP.NET tab. The Authentication tag contains a Roles area where role management (Role Management) is activated (you should check this out). The default SQL Server (LocalSqlServer) connection string is specified in the General tag. The development environment uses the following connection string:

The following is a reference clip:

Data source= database_server_name;Integrated Security=SSPI; Initial Catalog=aspnetdb;User Instance=false

Save these changes in the ASP.NET environment and connect it to the previously configured SQL Server instance. Once the platform is configured, execution can begin.

Defining elements of the basic ASP.NET tutorial

The data elements used in the personality file are established and saved in the web.config file (that is, the saved data values are defined in that file). The actual values (for different users) are stored in a terminal data warehouse. You can specify the name, data type, and how the data is serialized for each property.

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

ProviderSpecific: the default Profile provider determines how to serialize property values.

String: the property value is converted to a string.

Xml: property values are converted to XML form.

Binary: property values are converted to binary form.

The personality file element defined in the attribute element is contained in a personality file element, which is located in the system.web section of the web.config file. The web.config in listing An includes a personality file fragment that applies the previous personality file support. It will use two personality file items, FirstName and LastName--, which hold string values and allow anonymous users.

Personality file features can be applied to both anonymous and authenticated users. The previous web.config file specifies anonymous support by using the allowAnonymous attribute of the personality file element and activating the application anonymous support (anonymousIdentification element).

Use the code

Once the environment is configured correctly, you can easily apply personality file elements to your .NET code. The simple C # code in listing B uses personality file elements to store and display data values, using the Profile class contained in the System.Web namespace. The code contains the ASP.NET file after the code separation file.

Listing C contains code separation (codebehind) for custom code. * buttons store the value of each text field in the personality file field. The second button restores values from the personality file field and populates the text field with these values.

ASP.NET personalization of ASP.NET basic tutorials is more simplified

Personalization is just one of many new features in ASP.NET 2.0. After a few configuration steps, you can easily add personalization features to your application through standard web.config files and Profile class coding.

Thank you for your reading, the above is the content of "what are the personalized characteristics of ASP.NET". After the study of this article, I believe you have a deeper understanding of what the personalized characteristics of ASP.NET are, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report