Recently, we were facing this error while deploying the solution into server (IIS) as a separate application (Sub Domain) in a main web application.


I created a website ( say site mymainsite ) in window server IIS under a port and then added an another application ( plugin ) under a root-site ( mymainsite ) as shown:

After deploying the solution, when I opened the site, I got this error. OOps!!!

“The entry ‘DefaultConnection’ has already been added. (C:..\web.config line ..)”

With some research, I found that it was conflicting with the parent site connection provider. There was a same connection name (DefaultConection) in the parent site.

If you have another project using the same connection string name you will receive this error because that connection string has already been added to the collection.


Method 1:

We can fix this by updating the web.config file.

<remove name="DefaultConnection" />

Add above tag with connection string name just above the connection key.

Method 2:

Alternatively, you can clear all connection string adding below tag.

<clear />