In an ASP.NET MVC 3 web application I have the problem that settings from the web.config
file are completely ignored and the default values are applied. The relevant parts of the file are as follows:
...
<configuration>
<configSections>
<section name="MyProject.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=..." requirePermission="false" />
...
<applicationSettings>
<MyProject.Properties.Settings>
<setting name="MySetting" serializeAs="String">
<value>MyValue</setting>
</setting>
...
I made sure that the project name is correct and I also verified that the webserver user has access to the file (using ProcessMonitor
to monitor the access).
I also checked this post, but didn't get any further. Are there any other constellations where the web.config
settings might be ignored? I never had any problems with the approach shown above (i.e. reference one or more config sections), but today we spent a couple of hours trying to solve this problem and we can't see where we are wrong here.
Update 1
Following @jbl's comment I tried to access the settings as follows:
((ClientSettingsSection)ConfigurationManager.GetSection( "applicationSettings/MyProject.Properties.Settings" )).Settings.Get("MySetting")
Unfortunately, in a local test this (also) worked as expected, but on the server - again - the default values were used and the ones under applicationSettings in the web.config were ignored.
Update 2
Deleting the web application from IIS and creating a new one also didn't work.