Recently, we were facing this error while deploying the asp.net solution into server (IIS) as a separate application (Sub Domain) in a main web application.
Scenario
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.
Solutions
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 />
Cheers!!
Howdy I am so grateful I found your blog, I really found you by error, while I was looking on Google for something else, Anyways I am here now and would just like to say kudos for a marvelous post and a all round thrilling blog (I also love the theme/design), I don抰 have time to go through it all at the minute but I have bookmarked it and also included your RSS feeds, so when I have time I will be back to read a great deal more, Please do keep up the superb work.
Thank you!!