IIS: Cannot add duplicate collection entry

Running IIS 7.5 (Windows 7) on a development machine when I visit a site I have been working on and get the following error:

What?!? This was working just the other day and I hadn’t changed anything on this site. In fact, this site is just a vanilla WordPress site used for documentation. Other than a child theme there is no coding work done here.

So, I open up IIS and attempt to view the properties for this site and I am greeted with this error:

Ok this helps, there is a problem with the web.config file, having to do with default documents. I remember making a change in IIS recently with default documents. The problem is on line 6 of the web.config file so lets go look at that.

Not much here – were just adding a “index.php” as a default document to this site. Now, I know what is going on. When I setup PHP on this machine I added “index.php” to the list of the default documents for the site I was working on at that time. As I created new sites I added “index.php” as a default document local to the site.

A couple of days ago while adding another site and decided instead of adding “index.php” to the local site’s default documents I would add it to the IIS server’s list of default documents. This would be inherited by all the sites.

There it was I created a situation where the server had a default document of “index.php” and I had a site with a web.config file where I was attempting to add another default document of “index.php” – a duplicate collection entry.

Since, the addition of a default document was the only thing in the web.config the fix was simple – delete the web.config file (I renamed it to test before deleting). After deleting the web.config file IIS was able to display the site’s properties without error:

Viewing the default document properties for the site showed “index.php” was still a default document and it was inherited from the IIS server.

Advertisements