We have been developing asp.net mvc application. we have to maintain some user-specific information as long as user is logged in. What is the option for me? Cache is shared across all users of the site. Session seems to be the option but I have attached webforms for showing Crystal Reports and the Session object used by webforms and MVC is different: Mvc uses HttpSessionStateBase and webforms use HttpSessionState.
How much information should I keep in the session (I have an array of around 30 integers/user)? Should I keep it in the session or some combination of session and cache should be used instead?
Edit: I have created a SessionService that accepts HttpSessionStateBase as Parameter and from Mvc I'm calling it like:
SessionService _service = new SessionService(HttpContext.Session);
it returns HttpSessionStateBase but as Darin suggested it is abstract class so it might as well be using SessionStateWrapper implementation. In the web forms scenario I'm using something like
HttpSessionStateWrapper Session = new HttpSessionStateWrapper(HttpContext.Current.Session);
SessionService _SessionRepository = new SessionService(Session);
Session seems to be the option but i have attached webforms for showing crystal reports and the Session object used by webforms and MVC is different: Mvc uses HttpSessionStateBase and webforms use HttpSessionState.
HttpSessionStateBase
is an abstract class and it's implementation is simply a wrapper of the original HttpSessionState
object. So as long as you stay within the same application the session is exactly the same between MVC and WebForms and you would be able to share data using it. So in your scenario session seems a correct approach for persisting data.