Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Best place to add logged in user code?
Message
De
05/07/2010 04:37:59
 
 
À
05/07/2010 04:12:07
Information générale
Forum:
ASP.NET
Catégorie:
Autre
Versions des environnements
Environment:
C# 4.0
Divers
Thread ID:
01471365
Message ID:
01471374
Vues:
37
>>A continuation of the my user ID question. I am thinking about saving the UserID to a session variable if there is a valid user id and the session variable is empty. This would minimize my database hits. The web page I am working on has a master page with the header and login controls setup. Seems to me that if I always include that master page in my web pages then that would be the best place to put this code to make sure it runs on every hit. Is there a better place?
>>
>>Thanks.
>
>You could do it that way. Or just write the session variable from the log-in page. It depends on how likely it will be that the information will be needed.
>Also, if you need various bits of information about the user then you could put them in a custom class and store that in the session variable - only having the Id means you'd probably have to go back to the DB again anyway.

Update: I did this type of thing in a WPF application by implementing and extending the IIdentity object in my own class. Doing it that way means you should be able to just get the info you need from the HttpContext.User.Indentity rather than bothering with session variables. Not sure where you'd hook that in in ASP.NET tho :-{
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform