473,511 Members | 15,503 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

singleton in an aspx app?

Suppose I want to supply a singleton class object that will sit between my
intranet asp.net app and MS SQL database, doing al the chemistry with
connections etc inside of it.

The problem is that I don't really know how to keep the object persistent
for all the requests nade within the app.

I need the object to live for certain periods of time, and I need it to be
easily accessible from aspx.cs files' code.

I guess I will be creating it in global.asax on application start; where do
I store it then? How do I address it?
Nov 18 '05 #1
4 1707
Store it in the Application Context...

Reference it through the application context.
"Sergei Shelukhin" <ra******@home.domonet.ru> wrote in message
news:2t*************@uni-berlin.de...
Suppose I want to supply a singleton class object that will sit between my
intranet asp.net app and MS SQL database, doing al the chemistry with
connections etc inside of it.

The problem is that I don't really know how to keep the object persistent
for all the requests nade within the app.

I need the object to live for certain periods of time, and I need it to be
easily accessible from aspx.cs files' code.

I guess I will be creating it in global.asax on application start; where do I store it then? How do I address it?

Nov 18 '05 #2
"Sergei Shelukhin" <ra******@home.domonet.ru> wrote in
news:2t*************@uni-berlin.de:
Suppose I want to supply a singleton class object that will sit
between my intranet asp.net app and MS SQL database, doing al the
chemistry with connections etc inside of it.


Microsoft already has a set of classes which do this: Microsoft appplicaion
data blocks (you can download the classes from MSDN). Unless you're doing
something special, it's usually not a good idea to use a singleton
structure in ASP.NET.

--
Lucas Tam (RE********@rogers.com)
Please delete "REMOVE" from the e-mail address when replying.
http://members.ebay.com/aboutme/coolspot18/
Nov 18 '05 #3
Or in the "Cache" if that singleton can be weakly referenced. The only
difference between Cache and Application objects is that Application ones
are guarenteed to be there whenever you ask and Cached ones, you will need
to verify that they exist before using them.
Just another suggestion.

--
Girish Bharadwaj
http://msmvps.com/gbvb
"CJ Taylor" <[cege] at [tavayn] dit commmmm> wrote in message
news:ug**************@TK2MSFTNGP10.phx.gbl...
Store it in the Application Context...

Reference it through the application context.
"Sergei Shelukhin" <ra******@home.domonet.ru> wrote in message
news:2t*************@uni-berlin.de...
Suppose I want to supply a singleton class object that will sit between my intranet asp.net app and MS SQL database, doing al the chemistry with
connections etc inside of it.

The problem is that I don't really know how to keep the object persistent for all the requests nade within the app.

I need the object to live for certain periods of time, and I need it to be easily accessible from aspx.cs files' code.

I guess I will be creating it in global.asax on application start; where

do
I store it then? How do I address it?


Nov 18 '05 #4
Sergei Shelukhin wrote:
Suppose I want to supply a singleton class object that will sit
between my intranet asp.net app and MS SQL database, doing al the
chemistry with connections etc inside of it.

The problem is that I don't really know how to keep the object
persistent for all the requests nade within the app.

I need the object to live for certain periods of time, and I need it
to be easily accessible from aspx.cs files' code.

I guess I will be creating it in global.asax on application start;
where do I store it then? How do I address it?


For an exellent article about the singleton pattern (in C#) see:
http://www.yoda.arachsys.com/csharp/singleton.html


Nov 18 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
1548
by: VidalSasoon | last post by:
I am trying to set up a singleton since it seems like the best solution to my problem. I have a an object that I want to initialize when the program starts then I just want to call it like a...
21
2432
by: Sharon | last post by:
I wish to build a framework for our developers that will include a singleton pattern. But it can not be a base class because it has a private constructor and therefore can be inherit. I thought...
4
1397
by: Srini | last post by:
Hi , Can anyone tell me when I can use singleton pattern. Will it be good for implementing the dataaccess Layer. Will it be usefull for the buisness object layer . Could you give me a practicle...
5
3963
by: Bob | last post by:
Does anyone know of any adverse affects of using singleton data access objects in an ASP.NET Web Service? I've been forced to implement it this way but it just doesn't seem right to me. I haven't...
1
1227
by: Diffident | last post by:
Guys, I have been cracking my head over this concept in .NET framework. I have read many posts on this topic but not clear about this and hence I am posting it again. If you have designed...
14
3005
by: Paul Bromley | last post by:
Forgive my ignorance on this one as I am trying to use a Singleton class. I need to use this to have one instance of my Class running and I think I understand how to do this. My question however is...
2
2403
by: baba | last post by:
Hi all, I'm quite new to C#. I am trying to implement some basics reusable classes using this language and the .NET Framework technology. What I'm trying to do now is to implement a singleton...
11
1849
by: donet programmer | last post by:
Can somebody comment on the usage of the singleton pattern for maintaining session variables?? Thanks
6
2072
by: Palvinder Singh | last post by:
Hello google group peeps, I am new to remoting, but have a grasp of it. I am trying to create a server/client application, which will be deployed over an intranet. I have upwards of five...
0
7242
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7138
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7353
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
7075
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7508
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5662
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5063
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
1
781
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
446
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.