3

I am running a .NET 4.0 Web Application. Under IIS Express ( and only IIS Express ) none of my APPSettings are read into the AppSettings collection. When I look into this collection it is empty even though I have about 15 app settings in the web.config. Any sugguestions on what is going on?

This is a Web Application project. I am using web.config transformations but I believe those only are used when publishing.

Joshua Hudson
  • 2,187
  • 2
  • 20
  • 24
  • Check to see if its under the correct node. Make sure its in the node. And not one of its child nodes or outside of it – Evan Larsen Mar 30 '11 at 17:23
  • 1
    How do you read into the AppSettings collection? – airbai Apr 06 '11 at 08:49
  • var configurationAppSettings = new AppSettingsReader(); returnMe = ((int)(configurationAppSettings.GetValue(parameterName, typeof(int)))); as an example. Though I have used ConfigurationManager.AppSettings["test"] and it was empty as well. – Joshua Hudson Apr 06 '11 at 16:14

2 Answers2

5

One thing I've discovered that can cause appsettings not to load this is having a virtual directory nested in another directory

http://localhost:8181/xproject/mysite

changing it to

http://localhost:8181/xproject_mysite

fixed it for me.

I have no idea why though.

jbtule
  • 31,383
  • 12
  • 95
  • 128
0

Make sure that the the appSettings element in the web.config is a child element of the configuration element.

Craig
  • 6,869
  • 3
  • 32
  • 52