Cache question

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Alvin K

    #1

    Cache question

    Via the -global.asax- file, on application startup,

    the following code does not work:

    System.Web.Cach ing.Cache.Inser t (works on all other pages ...)

    whereas this works fine:

    HttpContext.Cur rent.Cache.Inse rt

    Can anyone explain why this is so?
  • William F. Robertson, Jr.

    #2
    Re: Cache question

    On application start there is no automatically mapped reference to the
    current Cache object.

    The object is handled through the HttpContext.Cur rent.

    When you reference the Cache object (or session or application) on a page,
    you are in the HttpContext.Cur rent by default.

    You will have to reference the Cache object through the HttpContext.Cur rent
    outside of a direct request for a page. That goes for a web control library
    or anything else outside a page request.

    I have even had trouble with it when I created two threads in the same web
    request.

    bill


    "Alvin K" <asianx74@yahoo .com> wrote in message
    news:cd0e8b44.0 307301239.3443d 399@posting.goo gle.com...[color=blue]
    > Via the -global.asax- file, on application startup,
    >
    > the following code does not work:
    >
    > System.Web.Cach ing.Cache.Inser t (works on all other pages ...)
    >
    > whereas this works fine:
    >
    > HttpContext.Cur rent.Cache.Inse rt
    >
    > Can anyone explain why this is so?[/color]


    Comment

    Working...