Can't access ApplicationState from MVC Controller

In my Application_Start method in the Global.asax I am setting the Application State to a string.  When I try and access it my controller I can't.  I thought I would access the Application State the same way as I do the Session State by saying:

string myvar = Application["MyString"];

When I try that, Application doesn't show up in Intellisense and I get the message: 'The name 'Application' does not exist in the current context'.

Here is a partial listing of my Application_Start method:
public class MvcApplication : System.Web.HttpApplication
{
    protected void Application_Start()
    {
        Application["MyString"] = "some value";
    }
}

Open in new window


Can someone please tell me what I am doing wrong?
dyaroshAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

käµfm³d 👽Commented:
string s = HttpContext.Application["MyString"] as string;

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
dyaroshAuthor Commented:
Thank you.  I had to use HttpContext.Current.Application["MyString"].
0
käµfm³d 👽Commented:
Hmmm...   It worked for me as I posted. Nevertheless, glad you got it working  = )

Screenshot
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
C#

From novice to tech pro — start learning today.