I need to display a value from the web.config
appSettings
section into a view.
I am using <%= Html.Label %>
to populate
In ASP.NET, I'd use ConfigurationSettings.AppSettings["FileServer"]
.
How do I do this in MVC??
You should be able to just use
<%= ConfigurationManager.AppSettings["FileServer"] %>
in your View.
By the way, ConfigurationSettings
is deprecated - you should use ConfigurationManager
Another pattern, use AppSettingsExpressionBuilder.
<asp:Literal ID="Literal1" runat="server" Text="<%$ AppSettings: sample%>" />
Put the value into TempData["MyVariableName"] using the AppSettings["MyVariableName"] method and then put the TempData value in your view.
In your controller:
TempData["FileServer"] = ConfigurationSettings.AppSettings["FileServer"]
In your view:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With