locked
Context become null in HttpModule RRS feed

  • Question

  • User137033276 posted

    Hi folks:

    In what situation, the HttpApplication.Context will get null. I found that in Init(), the Context intermittently become null so that I cannot get Cache from it.

    Thanks for any help.

    Thursday, October 15, 2009 6:58 AM

Answers

  • User312496708 posted

    check the asp.net application life cycle here. The context is not loaded along with cache as early as you are trying. So you need to check it after appropriate event only...

    http://msdn.microsoft.com/en-us/library/ms178473.aspx

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, October 15, 2009 7:26 AM
  • User863160722 posted

    The Cache property on the HttpContext object is simply a wrapper for the static Cache property on the HttpRuntime class. The HttpRuntime.Cache property should always be available.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, October 19, 2009 12:59 PM
  • User-1976337891 posted

    Hi,

    while using ajax, context will be null if the ajax tries to load axd files.

    check for null before you proceed.

    refer this : http://forums.lhotka.net/forums/thread/24604.aspx

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, October 20, 2009 8:35 AM

All replies

  • User312496708 posted

    check the asp.net application life cycle here. The context is not loaded along with cache as early as you are trying. So you need to check it after appropriate event only...

    http://msdn.microsoft.com/en-us/library/ms178473.aspx

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, October 15, 2009 7:26 AM
  • User863160722 posted

    The Cache property on the HttpContext object is simply a wrapper for the static Cache property on the HttpRuntime class. The HttpRuntime.Cache property should always be available.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, October 19, 2009 12:59 PM
  • User-1976337891 posted

    Hi,

    while using ajax, context will be null if the ajax tries to load axd files.

    check for null before you proceed.

    refer this : http://forums.lhotka.net/forums/thread/24604.aspx

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, October 20, 2009 8:35 AM
  • User-250014019 posted

    What about when running in web garden mode? Each worker has its own memory space. That is another thing to think about, caching in web garden/web farm configurations.

    Friday, October 23, 2009 1:29 PM