Singleton in ASP.NET 2.0

D

Dmitry

Hi,

can anybody explain me if singletons can be used in ASP.NET 2.0
applications without being shared by multiple users/sessions? The
problem is that my application is using another library which
internally uses singletons, which should not be shared across multiple
users (one of the things they have in there is DB transaction manager).
Any suggestions would be greatly appreciated.

Regards,
Dmitry.
 
S

sloan

I have a singleton (web style) object that I created to store objects.

http://spaces.msn.com/sholliday/ 10/24/2005 entry

My approach was that by piggy backing off the Session object... each
user gets their own version....much like a winform app would work.

I only store simple objects in mine .. (aka, what I've tested)....
mainly dealing with UI ... how I move from 1 page to the next with out
hard coded hrefs in the pages.

Anyway, take a look....but I'd say the idea is that you'd have 1 per
user.. by piggybacking off the Session object.

I use guids for my Users to ensure no conflicts, fyi.
 
B

Bruce Barker

Singletons is a design pattern.they can be used with asp.net if designed
correctly.

the issues with asp.net is that thread local storage can not be used as the
thread can change while processing the request (casing the data to
disappear). if your library has any static variables, and they are not to be
shared across all thread and users then your library won't work.

-- bruce (sqlwork.com)
 
D

Dmitry

Thanks Bruce,

I guess I'm in trouble now. But what about all those rumors that ASP.NET
sessions would run in separate app domains, not threads? That would
ensure that address space is not shared between different sessions?..
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top