0

I am trying to pull a value from my Web.Debug.Config file most specifically from the AppSettings, it's just a string "Here are the books". But I get an object reference not set to an instance of an object. What do I need to fix, I am just trying to pass this to a Text Box

     string s = System.Configuration.ConfigurationManager.AppSettings["mybooks"];
        TextBoxq.Text = s;

Thank you

Web.Debug.config app settings:

<appSettings>
     <add key="mybooks" value="my test label value"/>
</appSettings>
Andrew T Finnell
  • 13,417
  • 3
  • 33
  • 49
user710502
  • 11,181
  • 29
  • 106
  • 161

3 Answers3

3

Most likely problem is that you aren't using "WebDeploy" which means that the .Debug version of your config file is ignored. If that's the case, put the setting in Web.Config directly and try again. If that's not the case, post the relevant pieces of your config file so we can help.

Robert Levy
  • 28,747
  • 6
  • 62
  • 94
0

The files are not combined until published. Are you trying to read it while debugging?

See ASP.NET MVC3: Debug and Release app settings not working

Community
  • 1
  • 1
Nikki9696
  • 6,260
  • 1
  • 28
  • 23
0

Web applications looks specifically for a file called Web.config. Try renaming your 'Web.debug.config' to just 'Web.config'.

Katie Kilian
  • 6,815
  • 5
  • 41
  • 64
  • I was actually mitaken , I was confused by those two Web Config files but I see that the WebConfig (root of both) contains the actual WebConfig file. I added the but still no luck – user710502 Jun 08 '11 at 21:17