Note that there are some explanatory texts on larger screens.

plurals
  1. POMultiple Web.config files in Area using ASP.NET MVC2
    primarykey
    data
    text
    <p>I have a question on something that I thought would be a simple. I have an Area in my website and I'd like to create a Web.config file specific to this area but, no matter where I put this config file, the keys that I've set up in my appSettings are all returning "null" when I access them, so I'm not sure what I'm supposed to do. Here's my website structure:</p> <pre><code>Site [usual site stuff like Views, Models, Controllers] Web.config Areas MyArea Web.config [usual site stuff like Views, Models, Controllers] </code></pre> <p>my web.config on the main site looks something like...</p> <pre><code>&lt;?xml version="1.0"?&gt; &lt;configuration&gt; &lt;appSettings&gt; &lt;add key="MyMainKey" value="MyTestValue"/&gt; &lt;/appSettings&gt; &lt;!--all of the standard asp.net mvc config stuff --&gt; &lt;/configuration&gt; </code></pre> <p>My areas config looks something like</p> <pre><code>&lt;?xml version="1.0"?&gt; &lt;configuration&gt; &lt;appSettings&gt; &lt;add key="MyAreaConfigValue" value="MyAreaTestValue"/&gt; &lt;/appSettings&gt; &lt;!--all of the standard asp.net mvc config stuff --&gt; &lt;/configuration&gt; </code></pre> <p>In a controller action that exists in my Areas/MyArea/Controllers folder I'm trying to access it like so:</p> <pre><code>string my_area_config_val = System.Configuration.ConfigurationManager.AppSettings["MyAreaTestValue"]; </code></pre> <p>But my_area_config_val is null.</p> <p>In a controller action in my main site (not in my Area) I can do </p> <pre><code>string my_main_config_val = System.Configuration.ConfigurationManager.AppSettings["MyTestValue"]; </code></pre> <p>and my_main_config_val is equal to "MyTestVal", as expected.</p> <p>Thanks. Mustafa</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.
    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