Singleton-Pattern ASP.NET C#为每个用户 [英] Singleton-Pattern ASP.NET C# for each user

查看:116
本文介绍了Singleton-Pattern ASP.NET C#为每个用户的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用asp.net c#构建一个Web应用程序,我有一个类,我想在多个页面中使用,每次都会实例化它。我需要加载数据,在用户会话期间不要丢失数据。我想到了单例模式,但它共享了浏览器之间的类的实例。我如何解决问题?

解决方案

Singleton不是答案。请参阅会话状态 ViewState Cookies


i'm building a web application with asp.net c# and i have a class that i want to use in multiple pages witouth instantiate it every time. I need to load the data in it and never lose them during the user session time. I thought about the singleton-pattern but it shared the instance of the class beetween browsers. How can i solve the problem?

解决方案

Singleton is not the answer. Look at Session State, ViewState and Cookies.

这篇关于Singleton-Pattern ASP.NET C#为每个用户的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆