This is a discussion on "Maintaining state information across applications and pageloads" within the ASP.NET Forum section. This forum, and the thread "Maintaining state information across applications and pageloads are both part of the Program Your Website category.
|
|
|
|
|
![]() |
||
Maintaining state information across applications and pageloads
|
||
| Notices |
![]() |
|
|
LinkBack | Thread Tools |
|
|||
|
Maintaining state information across applications and pageloads
Question #1 : I'm trying to maintain a user's state information (name, birthdate, zipcode, etc.) across applications and pageloads.
What I've been doing thus far: 1) When a user logs in, generate a sessionId. 2) Store the sessionId in a database table along with the user's userId 3) Set a cookie with the user's sessionId 4) When an application loads, read the cookie, get the userId, and load the user's state information 5) Store the user's state information in ViewState Steps 4 and 5 must be repeated every time a user loads a new application. This causes a lot of DB accessing and does not maintain the user's state across applications. It also slows down pageloads due to high ViewState content. Is there a better way to do this? How do the "big sites" accomplish what I'm trying to do? Question #2 : I'm trying to share site configuration data (siteName, siteId, root url, etc.) between different applications on a given website. What is the best way to do this that doesn't involve files, database tables, or querystring arguments? I've considered using cookies to solve both Questions #1 and #2, but this seems risky and unreliable. Thanks for your help. |
|
|
|
|||
|
Re: Maintaining state information across applications and pageloads
My advice would be to use caching.
Typically I don't use session variables ad what I do is request the user data from the database each time. However if the data has already been requested the method would load it from cache rather than the database. e.g. Friend Function LoadMember(MemberId) as MemberObject Dim obj as Object = Cache("Member" & MemberId.ToString) End fucntion |
|
|||
|
Re: Maintaining state information across applications and pageloads
cant you edit on here? I hit post by mistake! DOH
Friend Function LoadMember(MemberId) as MemberObject Dim obj as Object = Cache("Member" & MemberId.ToString) if obj is nothing then ' load from database and add to cache cache("Member" & MemberId.tostring) = MemberObject1 return MemberObject1 else return ctype(obj,MemberObject) end if End fucntion |
![]() |
| Tags |
| maintaining, state, information, across, applications, pageloads |
| Thread Tools | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Useful tools / applications | mybmodel | E-Commerce and Business | 2 | Mar 24th, 2008 09:31 |
| Applications Engineer | Web JobBot | Job Opportunities | 0 | Nov 26th, 2006 08:45 |
| Applications Engineer | Web JobBot | Job Opportunities | 0 | Oct 5th, 2006 22:34 |
| Applications Engineer | Web JobBot | Job Opportunities | 0 | Oct 5th, 2006 22:18 |
| Updating/maintaining site problem | NovaGoth | Web Page Design | 6 | Apr 17th, 2006 05:56 |