I am using MVC application. I am updating an object's properties with the user related information in the HomePage controller's Display action method. HomePage/Display is the first action method that gets executed when the application url is opened. Display action fetches the user related information like past orders, ongoing orders etc from the database and the same is populated in the userInformation object.
I save this userInformation object in a session.
var userData = HttpContext.Current.Session["UInfo"] as userInformation;
I need this userData object in all the controllers. Hence in other controllers I access the userData object using the session i.e HttpContext.Current.Session["UInfo"] as userInformation. But if the thread is different then HttpContext.Current.Session["UInfo"] becomes null.
I have googled for the solution but most of them refer to storing simple string or using ViewModel for _Layout. I am aware that we can do it using TempData..but I am looking for any better or alternate solution for this.
How do i reuse a object that gets initialized in one controller and reuse the object in all the other controllers and views
Thank you.