Note that there are some explanatory texts on larger screens.

plurals
  1. POweb.config ignores Settings.Default.<Property> and always uses default value
    primarykey
    data
    text
    <p>In an ASP.NET MVC 3 web application I have the problem that settings from the <code>web.config</code> file are completely ignored and the default values are applied. The relevant parts of the file are as follows:</p> <pre><code>... &lt;configuration&gt; &lt;configSections&gt; &lt;section name="MyProject.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=..." requirePermission="false" /&gt; ... &lt;applicationSettings&gt; &lt;MyProject.Properties.Settings&gt; &lt;setting name="MySetting" serializeAs="String"&gt; &lt;value&gt;MyValue&lt;/setting&gt; &lt;/setting&gt; ... </code></pre> <p>I made sure that the project name is correct and I also verified that the webserver user has access to the file (using <code>ProcessMonitor</code> to monitor the access).</p> <p>I also checked <a href="https://stackoverflow.com/questions/192641/settings-default-property-always-returns-default-value-instead-of-value-in-per">this post</a>, but didn't get any further. Are there any other constellations where the <code>web.config</code> 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.</p> <p><strong>Update 1</strong></p> <p>Following @jbl's comment I tried to access the settings as follows:</p> <pre><code>((ClientSettingsSection)ConfigurationManager.GetSection( "applicationSettings/MyProject.Properties.Settings" )).Settings.Get("MySetting") </code></pre> <p>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.</p> <p><strong>Update 2</strong></p> <p>Deleting the web application from IIS and creating a new one also didn't work.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload