开发者

Regarding Profile and session in asp.net

开发者 https://www.devze.com 2023-02-13 09:01 出处:网络
what is the basic difference between session and profile. whatever we store in session that data can be access from any page in asp.net and whatever we store in 开发者_如何学Cprofile that data also ca

what is the basic difference between session and profile. whatever we store in session that data can be access from any page in asp.net and whatever we store in 开发者_如何学Cprofile that data also can be access from any page in asp.net from profile. i often store user specific data in session. so i just want to know in what kind of situation we store data in profile instead of session. another things i want to know whose performance is good session or profile. please discuss. thanks


Profile:

1- Profile object is scoped to a particular user: Each user of a web application automatically has his own profile.

2- Profile object is persistant: When you modify the stat os the profile object, the modifications are saved between visits to the website

3- Profile object uses the provider model to store information: By default, the contents of a user profile are automatically saved to a Microsoft SQL Server Express database located in App_Data of your web application.

4- Profile object is strongly typed: Using strongly typed properties has several advantages. For example, you get full Microsoft IntelliSense when using the Profile object in VS.NET 2005 or Visual Web Developer

Session:

1- Session object is scoped to a particular user: Each user of a web application automatically has his own Session state.

2- Session object is non-persistant: When you add an item to the Session object, the items disappear after you leave the Web site.

3- Session object uses three different ways to be stored: 3.1: In Process - default 3.2: State Server (Out of Process) 3.3: SQL Server

4- Session object is not strongly typed:

source: Profile VS Session


Session data will last for the lifetime of the session. Profile data is held in the asp.net database so it can persist over a number of sessions dependent on the credentials of the authenticated user.


Other than Hawxby's and Davide Piras answers, which are technically correct, I also feel that there is a conceptual difference between Profile and Session. I feel that properties of the Profile are attributes of the session's user, where as the Session should include properties of the session. For instance, in my app I use Profile properties because I frequently call Session.Clear() for security and efficiency concerns, without worry that I'm losing attributes of the user.

0

精彩评论

暂无评论...
验证码 换一张
取 消