我们一直在开发asp.net mvc应用程序。只要用户登录,我们就必须保留一些特定于用户的信息。那么我有什么选择呢?缓存是整个站点所有用户共享的。Session似乎是一个选项,但我已经附加了WebForms以显示Crystal Reports,而WebForms和MVC使用的Session对象不同:Mvc使用HttpSessionStateBase,而WebForms使用HttpSessionState。
我应该在会话中保存多少信息(每个用户都有一个大约30个整数的数组)?我应该将其保存在会话中还是应该使用会话和缓存的组合?
编辑:我创建了一个SessionService,它接受HttpSessionStateBase作为参数,并从Mvc中调用它:
我应该在会话中保存多少信息(每个用户都有一个大约30个整数的数组)?我应该将其保存在会话中还是应该使用会话和缓存的组合?
编辑:我创建了一个SessionService,它接受HttpSessionStateBase作为参数,并从Mvc中调用它:
SessionService _service = new SessionService(HttpContext.Session);
它返回HttpSessionStateBase,但正如Darin所建议的那样,它是抽象类,因此可能正在使用SessionStateWrapper实现。在Web表单方案中,我正在使用类似以下内容的东西
HttpSessionStateWrapper Session = new HttpSessionStateWrapper(HttpContext.Current.Session);
SessionService _SessionRepository = new SessionService(Session);