c# - How to persist logged in user data for entire session? -
i'm creating practice admin application using mvc4, i'm not sure best method persist logged in user data entire lifetime of session accessible views & controllers.
for example, desire user log in, download user data database, , entire session want maintain user model (name, database id etc) it's accessible throughout entire web application until user logged out.
is best approach store data in encrypted cookie? or there way of using static class?
currently i've read using viewmodel base class so:
public abstract class viewmodelbase { public usermodel user { get; set; } }
then of viewmodels can inherit base class, providing access user data model:
public class allemployeesviewmodel : viewmodelbase { public list<employeemodel> employees { get; set; } }
however, if in 1 controller action set user data, lost when loading controller action.
to me seems waste of resources & increase load times have keep downloading user data database in every action.
all advice welcome new web programmer. if i've missed important details, please request , try best answer.
you should sessionstate store data duration of user's browser session.
http://msdn.microsoft.com/en-us/library/vstudio/ms178581(v=vs.100).aspx
Comments
Post a Comment