The Importance of Removing Elements from Web.Config
Published on December 15, 2011 | Filed Under ASP.NETI admit it. I’m hard-headed. In fact, I tend to ignore simple programming rules, just because I think I’m great at paying attention. Unfortunately, even I make mistakes.
Recently, I was doing a website upload and my server finally caught on to one of my games: I had a sub-application with a web.config file that used the same connection string name as my main application. As far as ASP.NET and IIS are concerned, I shouldn’t have been allowed to get away with this. I suppose that night just wasn’t my night.
Since this was a sub-application, it wasn’t in my normal list of checks-and-balances for an after-upload run-through. So it wasn’t until the next morning that I received the following message:
The entry ‘MainConnection_Test’ has already been added.
Of course, my users had no clue what this error meant and my boss just wanted it to be fixed.
So how do you fix this error? Just add one line to your web.config file:
<remove name="MainConnection_Test" />
Place that just above your connection string.
So in a generic example, your web.config would look like this:
<connectionStrings>
<remove name="{Name}" />
<add name="{Name}" connectionString="{String}"/>
<remove name="{Name2}" />
<add name="{Name2}" connectionString="{String}"/>
</connectionStrings>
Just follow this rule for all of your connection strings.
So I have learned my lesson about taking two seconds to safeguard myself. Don’t fall into the same trap that I did!
~Derek Torrence
Hey Look what we have for you! a fineoffering
To qualify click on the link below
https://drive.google.com/file/d/1neswkzIHLWQrxOiVtu4d-4q0lByJ0y22/preview
What we succour here is , a believablecontribution
Licit click
https://drive.google.com/file/d/1sH3pzDfsWKfYX6papY4hOctWJL9unahF/preview
a okoblation
Fitting click
https://drive.google.com/file/d/1Heb6k4brNqSneTaF-K2-qFYh6bHdjPd_/preview