asp.net 2 sexual placement (profile) __.net

Source: Internet
Author: User
Tags stack trace sql server express connectionstrings
asp.net 2 sexual placement (profile) Luyikk launched the topic at 2007-9-23 4:27 1building [Landlord] store configuration information for each user
Strong type long-term save support for anonymous users
Definition configuration (Profile)
? XML version= "1.0"?>

< configuration xmlns = "http://schemas.microsoft.com/.NetConfiguration/v2.0" >
< appSettings/>
< connectionstrings >
< add name = "Northwind" connectionString = "server=localhost;integrated security=true;database=northwind" ProviderName = "System.Data.SqlClient"/>
</connectionstrings >
< system. Web >

< anonymousidentification enabled = "true"/>
< profile >//Definition configuration (Profiles)
< properties >
< add name = "Theme" allowanonymous = "true"/>
< add name = "Lastvisit" type = "System.DateTime" allowanonymous = "true"/>
</Properties >
</profile >
<!--
<webParts>//Definition configuration (WebParts)
<personalization defaultprovider= "Aspnetsqlpersonalizationprovider"/>
</webParts>
-->
<!--
Set compilation debug= "true" to insert debugging symbols into the compiled page.
Because this affects performance, the set this value to true only during development.
-->
< compilation debug = "true" >
< expressionbuilders >
< add expressionprefix = "Version" type = "Versionexpressionbuilder"/>
</expressionbuilders >
</compilation >
<!--
The <authentication> section enables configuration of the security authentication
Mode used by ASP.net to identify a incoming user.
-->
< authentication mode = "Windows"/>
<!--
The <customErrors> section enables configuration of what to did if/when an unhandled
Error occurs during the execution of a request. Specifically, it enables developers
To configure HTML error pages to is displayed in place of a error stack trace.
-->
< customErrors mode = "RemoteOnly" defaultredirect = "genericerrorpage.htm" >
<!--
<error statuscode= "403" redirect= "noaccess.htm"/>
<error statuscode= "404" redirect= "filenotfound.htm"/>
-->
</customErrors >
</system.web >
</configuration >

Use configuration (Profile)
Increment the current user ' s post cout
Profile.posts = profile.posts+1;
Update the current user "s Last Post Date
Profile.lastpost = DateTime.Now;

Personalization data will be stored in the database

Introduced
Microsoft asp.net 2.0 supports a new object called Profile, which automatically stores user information between access to multiple Web applications. A user profile can store various types of information that can be either simple string and integer types or complex custom types. For example, you can store the user's last name, shopping basket, user attributes, or site usage statistics.
In this article, you will learn how to define user profile in an application. We will also show you how to configure profile with different provider. Finally, you will learn how to manage and generate user profile reports.

User Profiles Commanding
The profile object is very similar to the session object, but is better used. The similarity to the session is that profile is relative to a particular user, that is, each Web application user has its own profile object. Unlike the session, the profile object is a persistent object. If you add an item to the session, the item disappears when you leave the site. While profile is completely different, when you modify profile state, the modification is effective between multiple accesses.

Profile uses the provider mode to store information, and by default the contents of user profiles are stored in the SQL Server Express database, which is located in the App_Data directory of the Web site. However, in the latter part of this article, you will learn how to use other data providers (provider) to store information, such as a database in a full version of SQL Server or an Oracle database.

Unlike sessions, profile is strongly typed, the session object is only a collection of items, and the profile object has strongly typed attributes.
There is a reason for using a strong type. For example, with a strong type, you can use IntelliSense in Microsoft Visual Web developer, and when you type profile and a point, IntelliSense pops up the list of profile attributes you've defined.

Define user Profile
You can define a user profile either in Machine.config or in web.config, Since you cannot create a Web.config file in the application's level two directory that contains the file Profile section, this means that you will not be able to define more than two profiles in one application.
In the web.config of Listing 1, an example of a simple profile definition is given, which has three properties, FirstName, LastName, and Pagevisits.
List 1
< configuration >
< system. Web >
< authentication mode = "Forms"/>

< anonymousidentification enabled = "true"/>

< profile >
< properties >
< add
Name = "FirstName"
DefaultValue = "??"
allowanonymous = "true"/>
< add
Name = "LastName"
DefaultValue = "??"
allowanonymous = "true"/>
< add
Name = "Pagevisits"
Type = "Int32"
allowanonymous = "true"/>
</Properties >
&nbs

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.