Thursday, February 17, 2011

Error accessing the Cache in the Application_Start method of Global.asax

I am trying to access the Cache in the Application_Start method of Global.asax. I am trying to accdess Context.Cache. When I run the code from visual studio it works just fine but when I run it on the server from IIS I get: Session state is not available in this context. I want to seed some values in the cache when the application starts. How can I get at the cache from Application_Start?

From stackoverflow
  • Wow. I found the answer to this. Use the variable HttpRuntime.Cache instead of Context.Cache.

  • Thanks for the answer @minty. You saved the day!!

0 comments:

Post a Comment