How to get Application State from a class

  • Thread starter Thread starter Quentin Huo
  • Start date Start date
Q

Quentin Huo

Hi:

In Application_Start method in the global.asax, I created an application
state: Application["test"]="...".

I can get the value from the each page, but I cannot get it in the class
that is called from a page. I always get an error as:

Object reference not set to an instance of an object.
......


I have to make the class inherit from System.Web.UI.Page class? Any other
way?

Thanks

Q.
 
Simply use this full namespace from within your class:
System.Web.HttpContext.Current.Application["test"]
 
Back
Top