Session scope

  • Thread starter Thread starter Eduardo Pavinato Klein
  • Start date Start date
E

Eduardo Pavinato Klein

Hi.

I've constructed a class in the singleton model, like this:


class MyClass
{
private MyClass instance;

public MyClass GetInstance()
{
if (this.instance == null)
this.instance = new MyClass();

return this.instance;
}

private MyClass () { ... }
}


It seems that in ASP.NET my instance belongs to the application, because
each session gets the same instance.
What to do in order to each session has its own instance?

Thanks,
Eduardo
 
in asp.net, page requests are handled by a thread pool of app, so any
sington is shared across all threads. also asp.net change which thread is
processing a single page request at its whim (thread agile). this mean if
you want global data tied to a page request you have to inhert from
ContextBoundObject

-- bruce (sqlwork.com)
 

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

Back
Top