C# – Error accessing the Cache in the Application_Start method of Global.asax

asp.netcglobal-asaxiis

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?

Best Answer

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