In Visual studio, Solution->Web.Project->Properties->Web, I have changed my Project Url from http://localhost:51123/ to http://localhost:51123/NewProjectName and I keep getting this error:

"Cannot add duplicate collection entry of type 'add' with unique key attribute 'name' set to ...." on every module added.

Adding a remove tag works but then it should have been a problem even before i changed the url. Any suggestions?

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:

  1. Added the same key twice in the same file (unlikely since you would've seen it)
  2. 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>&lt;system.webServer&gt; &lt;modules runAllManagedModulesForAllRequests="true"&gt; <b> &lt;remove name="ErrorLog" /&gt; &lt;remove name="ErrorMail" /&gt; &lt;remove name="ErrorFilter" /&gt; </b> &lt;add name="ErrorLog" type="Elmah.ErrorLogModule, Elmah" preCondition="managedHandler" /&gt; &lt;add name="ErrorMail" type="Elmah.ErrorMailModule, Elmah" preCondition="managedHandler" /&gt; &lt;add name="ErrorFilter" type="Elmah.ErrorFilterModule, Elmah" preCondition="managedHandler" /&gt; &lt;/modules&gt; &lt;/system.webServer&gt; </code></pre>