Static members are also not thread-safe..which is dangerous in ASP.Net.
What I've seen most people do is use a smart provider.
public interface IStateInformation
void Add(object key, object value);
void Remove(object key);
...
end interface
interneal class WebState : IStateInformation
public void Add(object key, object value){
HttpContext.Current.Session.Add(key, value);
}
public void Remove(object key){
HttpContext.Current.Session.Remove(key);
}
}
internal class WindowsState : IStateInformation
private static Hashtable _state = new Hashtable;
public void Add(object key, object value){
WindowsState._state.Add(key, value);
}
public void Remove(object key){
WindowsState._state.Remove(key);
}
}
public class StateProvider{
public statc IStateInformation GetProvider{
get {
return (HttpContext.Current != null) ? new WebState() : new
WindowsState();
}
}
}
Anyways, I have no doubt my implementation is bogus..but hopefully it gets
you off in the right direction....I think my WindowState is really
screwed...I'm stuffy..can't tthink...
karl
--
MY ASP.Net tutorials
http://www.openmymind.net/ - New and Improved (yes, the popup is
annoying)
http://www.openmymind.net/faq.aspx - unofficial newsgroup FAQ (more to
come!)
"Mantorok" <no**@tiscali.co.uk> wrote in message
news:d1**********@newsfeed.th.ifl.net...
"Karl Seguin" <karl REMOVE @ REMOVE openmymind REMOVEMETOO . ANDME net>
wrote in message news:Or**************@TK2MSFTNGP09.phx.gbl... No. You could use instance properties instead, but then you'd have to
carry
around the instance in the session for it to persist from request to
request. You'll likely need to explain your needs in more detail in
order to get any useful help..specifically with respect to why you can't use
sessions and what you are trying to do..
No is all I needed to know, the reason I asked is because the ASP.Net is
using a framework we developed for use on a windows forms client,
obviously if you fire up the app more than once you get a clean slate, but with
ASP.Net it is session-based.
So rather than relying on the static member used by the framework, I'll
need to adjust to Session variables.
Thanks
Kev
--
MY ASP.Net tutorials
http://www.openmymind.net/ - New and Improved (yes, the popup is
annoying)
http://www.openmymind.net/faq.aspx - unofficial newsgroup FAQ (more to
come!)
"Mantorok" <no**@tiscali.co.uk> wrote in message
news:d1**********@newsfeed.th.ifl.net... Hi
I have an ASP app which references a few static properties in some of
the classes. I understand that you should use Session variables, but is it
"possible" to have each session "not" reference the same static
members.
For example if I update the static member on one session this change
will be reflected on somebody elses session, which I don't want.
I hope there's an easy solution for this as changing to session
variables may prove to be a pain.
Thanks
Kev