MVC 2.0 c# asp.net 4.0 从会话中共享的库实例化对象
我正在尝试使用 MVC 2.0 框架来实例化库的对象。
我希望每次使用不同的浏览器导航应用程序(创建新会话)时都能够实例化该对象,并从维护分离不同会话对象的控制器中调用该对象的方法。
我必须在哪里存储和实例化我的对象?
谢谢
I'm trying to use the MVC 2.0 framework to instantiate an object of a library.
I want to be able to instantiate this object every time I navigate my application with a differnt browser (creating new session) and call methods on this object from my controllers mantaining separated the objects of different sessions.
Where do I have to store and instantiate my object?
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果对象的范围是会话,那么我会将其存储在会话缓存中。
您需要在控制器的构造函数中测试它是否存在,如果不存在,则创建并存储在会话中。
If the object's scope is session then I'd store it in the session cache.
You'll want to test in the controller's constructor if it exists, if not then create and store in the session.