Static variables on IIS 5

M

Mark Stevens

I have an ASP.NET (.NET 2) application with a something similar to the
following:

public static class A
{
protected static string str;
// Other methods...
}

Public Class B : A
{
// Public methods using str...
}

My query concerns the singleton nature of str. So if my site has two
users logged does each see their own version of the singleton class or
a shared one?

I would expect that the class is singleton to the user but I cannot
find anything which confirms this.

Thanks in advance,
Mark
--
|\ _,,,---,,_ A picture used to be worth a
ZZZzzz /,`.-'`' -. ;-;;, thousand words - then along
|,4- ) )-,_. ,\ ( `'-' came television!
'---''(_/--' `-'\_)

Mark Stevens (mark at thepcsite fullstop co fullstop uk)
 
A

Alvin Bruney [MVP]

Well, let's qualify that a bit. True singletons are exceedingly difficult to
create in a web environment so while it may be shared across all users,
there may be more than one copy of str - one for each worker process - in a
web farm.

--
Regards,
Alvin Bruney
------------------------------------------------------
Shameless Author Plug
OWC Black Book 2nd Edition
Exclusively on www.lulu.com/owc
$19.99


Eliyahu Goldin said:
It will be shared across all users. "Static" means application scope, not
session scope.

--
Eliyahu Goldin,
Software Developer
Microsoft MVP [ASP.NET]
http://msmvps.com/blogs/egoldin
http://usableasp.net


Mark Stevens said:
I have an ASP.NET (.NET 2) application with a something similar to the
following:

public static class A
{
protected static string str;
// Other methods...
}

Public Class B : A
{
// Public methods using str...
}

My query concerns the singleton nature of str. So if my site has two
users logged does each see their own version of the singleton class or
a shared one?

I would expect that the class is singleton to the user but I cannot
find anything which confirms this.

Thanks in advance,
Mark
--
|\ _,,,---,,_ A picture used to be worth a
ZZZzzz /,`.-'`' -. ;-;;, thousand words - then along
|,4- ) )-,_. ,\ ( `'-' came television!
'---''(_/--' `-'\_)

Mark Stevens (mark at thepcsite fullstop co fullstop uk)
 

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

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top