Re: Under what context Application events run in Global.asax
From: Joe Kaplan \(MVP - ADSI\) (joseph.e.kaplan_at_removethis.accenture.com)
Date: Wed, 11 Feb 2004 20:34:35 -0600
Did you try HttpRuntime.Cache?
Hopefully that is initialized by then.
I don't think you can expect to get the context object in a timer event as
there may not be a request in the pipeline.
"Ram" <firstname.lastname@example.org> wrote in message
> (I am running .NET Framework 1.1)
> I have a timer(System.Timers.Timer) running in my Global.asax page. In
> the timer.elapsed event I am trying to access an object I stored in
> the Cache.
> HttpContext.Current.Cache("xxx"). I am getting an error saying that
> HttpContext.Current is nothing.
> I also tried to check HttpContext.Current.User.Identity.Name and got
> an error and it says HttpContext.Current.User is nothing.
> I tried to get HttpContext.Current.User.Identity.Name in
> Application_onstart event and got the same error -
> HttpContext.Current.User is nothing.
> Can someone please tell me where I am going wrong.
> It is very critical for my project to access the cache object in the
> timer.elapsed event.