MVC Application variable
Posted on 2013-10-18
I want to read text from TSQL and put it all over the place. It is a legal disclaimer and it will be that same for every guest of a given role. There are 3 roles and three disclaimers.
I can put the text in a application variable in the Global.aspx file. But I do not know how to access it in the various cshtml pages.
These seems to work.
protected void Application_BeginRequest(Object sender, EventArgs e)
Application["GlobalVar"] = "GlobalValue"; // Add here global variable
But code like this in the controller says "Application" is undefined. How can I access it?
Response.Write("This is global variable " + Application["GlobalVar"]);