All web.config
files work off multiple cascading levels of inheritance at the machine, IIS, project, and folder level locations, with each providing a higher degree of specificity.
If you're getting this error, it means you've either:
- Added the same key twice in the same file (unlikely since you would've seen it)
- The same key already exists in a separate file higher up the inheritance chain
There can be a lot of different root causes for #2, but if you want to side step them, you can just remove any previous declarations and then re-add your own at that level (I'd pay good money for an upsert feature).
So just add <remove>
tags like this for any offending elements:
<!-- language: lang-xml -->
<pre><code><system.webServer>
<modules runAllManagedModulesForAllRequests="true">
<b>
<remove name="ErrorLog" />
<remove name="ErrorMail" />
<remove name="ErrorFilter" />
</b>
<add name="ErrorLog" type="Elmah.ErrorLogModule, Elmah" preCondition="managedHandler" />
<add name="ErrorMail" type="Elmah.ErrorMailModule, Elmah" preCondition="managedHandler" />
<add name="ErrorFilter" type="Elmah.ErrorFilterModule, Elmah" preCondition="managedHandler" />
</modules>
</system.webServer>
</code></pre>