Application state does not exist error?

  • Thread starter Thread starter Bruce W.1
  • Start date Start date
B

Bruce W.1

I thought that using the Application state, like this:
Application["SomeValue"] = "whatever";
was visible to the entire ASP.NET application.

But from another class I created I get the compile error:
The name 'Application' does not exist in the class or namespace...

What's the beef? Why can't it find it? How can I fix this?

Thanks for your help.
 
i suspect you are trying to access Application state from a seperate class library, if this is the case, you will need to add a using/imports statement for System.Web. you will then need to access the current context, like so:

HttpContext _context = HttpContext.Current;
string result = _context.Application["SomeValue"];

using this example will allow you to access any/all members of the current context, including cookies, session, etc.

hth (feel free to email me)
jayson
 
Back
Top