Question

In an ASP.Net MVC 1.0 applicati0n, is it possible to access the application settings (MyProject.Properties.Settings.Default.*) from inside my View (aspx page)?

I've tried but the intellisense and compiler don't like it. It says that it is inaccesible due to the protection level.

Was it helpful?

Solution

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.

OTHER TIPS

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 modifier enter image description here

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top