You should read this article to get a better understanding of the lifetime
of static members in ASP.NET.
http://blogs.msdn.com/tess/archive/2...23/516139.aspx
In short, statics are not evil, but you have to understand that they don't
die until the AppDomain dies. In ASP.NET, the AppDomain can live for quite
a long time, allowing you to build up lots of references to whatever you are
stuffing into the static in the AddToRepository method.
--
Kirk Allen Evans
Developer Evangelist
Microsoft Corporation
blogs.msdn.com/kaevans
=== This post provided "AS-IS" with no warranties and confers no rights ===
<dm***********@gmail.com> wrote in message
news:11*********************@j55g2000cwa.googlegro ups.com...
I'm relatively new to web services and I stumbled on some code that
maintains state between calls using a class with static members. This
is not the actual code, but you get the gist:
[WebMethod]
void AddToRepository(string name, int v)
{
ClassWIthStaticMember.AddToRepository(name, v);
}
[WebMethod]
int GetFromRepository(string name)
{
return ClassWIthStaticMember.GetFromRepository(name, v);
}
It seems to work, at least in the short term, but I'm concerned that
this is a very unreliable way of doing things. I'm not sure what the
lifetime of those static methods will be.
Any thoughts?