How to get Application State from a class

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.
 
S

Steve C. Orr [MVP, MCSD]

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

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top