caching - ASP.NET - How can I cache user details for the duration of their visit? -


I have created a repository that gets user information

  public event GetUserByOpenID (ByVal as openid string) User IUserRepository.GetUserByOpenID Dim User = (as the tool of U. dc.Users where u.OpenID = OpenID in the selection) .FirstOrDefault Return the end user function  

And I would like if users log in to be able to pull those details down And if the cached data is zero.

What is the best way to create a user object that includes all user details, and keep it on the entire site for the duration of its journey?

I was trying it out in my Global. ASX, but I'm not really happy session variables I would rather have an object with all the details inside. Private Sub BaseGlobal_AcquireRequestState (ByVal, in the form of this object, in the form of ByVal E. System.EventArgs) handles Me.AcquireRequestState sessions ("username") andalso User.Identity. IsAuthenticated then retarded UrbanNow.Core.IUserRepository = New UrbanNow.Core.UserRepository Dim _user New UrbanNow.Core.User _user = repo.GetUserByOpenID (User.Identity.Name) session ("user name is in the form of") = _user.UserName () session ("user id") = _user.id end then end sub

Full usage in a session variable instead of just a member Store the object.

  // store session ("UserInfo") = _user // read Dim user = DirectCast (session ("UserInfo"), UrbanNow.Core.User)  

(Code is converted to vb.net by online converter, I am sorry for any syntax errors, do not know any vb.net address)


Comments

Popular posts from this blog

windows - Heroku throws SQLITE3 Read only exception -

lex - Building a lexical Analyzer in Java -

python - rename keys in a dictionary -