Access key value from Web.config in Razor View-MVC3 ASP.NET
How do I access a key value from web.config in my Razor view.
This is in my web.config
in the Web Project root level.
<appSettings>
<add key="myKey" value="MyValue"/>
</appSettings>
I want to have to use the key in my Razor view.
Thank you.
@System.Configuration.ConfigurationManager.AppSettings["myKey"]
The preferred method is actually:
@System.Web.Configuration.WebConfigurationManager.AppSettings["myKey"]
It also doesn't need a reference to the ConfigurationManager assembly, it's already in System.Web.