MikeTWebb
MikeTWebb

Reputation: 9279

MVC3 VS2010 Application Settings i9mplementation

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

Answers (1)

Darin Dimitrov
Darin Dimitrov

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

Related Questions