Marina
7/18/2003 6:18:00 PM
This isn't the exact equivalent of session though. Your session_start and
sesion_end events won't fire in the same way. Also, how will you clean up
objects after the timeout has been reached? If you don't, this hashtable
will get huge over time...
"Nathan Baulch" <nathan.baulch@microsell.com.au> wrote in message
news:eQm5C6STDHA.1688@TK2MSFTNGP11.phx.gbl...
> > I'd rather not have to create my own static Hashtable of Hashtables
> > if there is a switch somewhere.
>
> This proved to be easier than I thought.
> Can anybody see any issues or suggest any optimizations in my
implementation
> below?
>
>
> public class Utils {
> public static Hashtable Session {
> get {
> string key = "Session_" +
> HttpContext.Current.Request.UserHostAddress;
> Hashtable session = (Hashtable)HttpContext.Current.Cache[key];
> if(session == null) {
> session = new Hashtable();
> HttpContext.Current.Cache.Insert(
>
> key,session,null,DateTime.MaxValue,TimeSpan.FromHours(1));
> }
> return session;
> }
> }
> }
>
>
> Nathan
>
>