Asp.net应用程序单例 [英] Asp.net application singleton

查看:97
本文介绍了Asp.net应用程序单例的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

对于高创建成本对象或具有绑定资源的对象(即嵌入式数据库),是否有一种方法可以为整个asp.net Web应用程序创建一个全局单例。



我试过添加一个单例但是如果请求停止一段时间(几秒钟)似乎会重新创建。

Is there a way to have a global singleton for the entire asp.net web application for high create cost objects or those with bound resources (i.e. an embedded database).

I have tried adding a singleton but it seems to be recreated if the requests stop for a period of time (a couple of seconds).

推荐答案

基本上是Singleton模式不是Web应用程序的首选项。



应用程序状态是一种Singleton,因为它是每个用户和整个应用程序的一个对象。
Basically Singleton pattern is not preference for Web Application.

Application state is a kind of Singleton in the sense it's one object for every user and whole application.


这篇关于Asp.net应用程序单例的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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