Reputation: 9279
I have an MVC2 C#.Net web app using VS2010. Below is an entry in y web.config:
<configuration>
<applicationSettings>
<BOE.My.MySettings>
<setting name="AppBackColor" serializeAs="String">
<value>AntiqueWhite</value>
</setting>
</BOE.My.MySettings>
</applicationSettings>
</configuration>
However, in my Controler.cs file My.Settings.AppBackColor is unrecognized. Any ideas?
var backColor= My.Settings.AppBackColor
What am I doing wrong here?
Upvotes: 0
Views: 487
Reputation: 1038710
That's Desktop application stuff. In web applications you don't use such settings.
You could use the <appSettings>
section of your web.config to store custom values:
<appSettings>
<add key="foo" value="bar" />
</appSettings>
and then when you want to read foo
:
var foo = ConfigurationManager.AppSettings["foo"];
Upvotes: 1