467,910 Members | 1,650 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 467,910 developers. It's quick & easy.

Static variables on IIS 5

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)
Oct 31 '07 #1
  • viewed: 1214
Share:
3 Replies
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" <ne***@nospam.nospamwrote in message
news:44********************************@4ax.com...
>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)

Oct 31 '07 #2
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" <RE**************************@mMvVpPsS.orgwrote in
message news:%2****************@TK2MSFTNGP04.phx.gbl...
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" <ne***@nospam.nospamwrote in message
news:44********************************@4ax.com...
>>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)


Oct 31 '07 #3
Thanks for the help. Confirms what I thought.

Regards,
Mark

Nov 1 '07 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by James | last post: by
2 posts views Thread by katekukku | last post: by
9 posts views Thread by Bryan Parkoff | last post: by
8 posts views Thread by Simone Chiaretta | last post: by
16 posts views Thread by RB | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.