Within my application the user will login, after they login I need to somehow keep track of the session that they have just created. Once they log in they have two options, enter the building and be done with the login process or check out equipment for their session. I need to keep track of that session within the application for the item check out. But I do not want to have to pass the current session model throughout each view before the equipment view? Currently I am using TempData, but I feel like this is playing with fire as I read somewhere temp data is cleared after two redirects I believe? Is there a permanent temp data or something else I can use that is safer? Thanks for the help.
You can store this data as session state. No need to pass it explicitly to the controller, it is part of the HttpContext which can be accessed inside any controller action.
MyUserContextData current = null;
// retrieve
if (HttpContext.Current != null && HttpContext.Current.Session != null) {
current = HttpContext.Current.Session["UserContextData"] as MyUserContextData;
}
// store
if (HttpContext.Current != null && HttpContext.Current.Session != null) {
HttpContext.Current.Session["UserContextData"] = current;
}
ASP.NET Session State Overview
Be warned that using Session State may prevent concurrent requests.