Access application settings from ASP.Net MVC View Access application settings from ASP.Net MVC View asp.net asp.net

Access application settings from ASP.Net MVC View


I had a similar issue to Saajid Ismail where my settings were in the namespace.Properties.Settings.Default.Setting they were there as they are strongly typed..

To make them accessible I simply had to change the access modifierenter image description here


Your View should only be responsible for rendering data given to it by the Controller. It's responsibility is for layout. So I would recommend passing the Application data to the view from within your Controller action.

Having said that, the technical answer to your question is that ViewPage derives from Page, so you can simply do this:

<%= Context.Application["setting"] %>

But again, I don't recommend it.