user1526912
user1526912

Reputation: 17300

How to fix duplicate entry error in web.config

I uploaded my C# web application to GoDaddy and getting Web.config errors while accessing certain areas of my site.

I do not get the errors running the same web.config and code in my local environment.

Description:

An error occurred during the processing of a configuration file required to service this request. Please review the specific error details below and modify your configuration file appropriately.

Parser Error Message: The entry 'xxxxx' has already been added.

In my configuration file . This is the section I believe that’s causing the errors.

<configuration>
  <configSections>
    <!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
    <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />

    <section name="paypal" type="PayPal.Manager.SDKConfigHandler, PayPalCoreSDK" requirePermission="false" />

  </configSections>

  <paypal>
    <settings>
      <add name="endpoint" value="https://api.sandbox.paypal.com"/>
      <add name="connectionTimeout" value="360000"/>
      <add name="requestRetries" value="1"/>
      <add name="ClientID" value="id"/>
      <add name="ClientSecret" value="secret"/>
    </settings>
  </paypal>

<configuration>

The error message suggest that I have duplicate values in my Web.config… Each time the error occurs I remove the suggested duplicate entry and try again.

However the error keeps occurring .

I have seen the followoing recommend solutions in another post however Im not sure where to put them.

<remove name="xxx" />
<clear />

Can you please help.

Upvotes: 2

Views: 2275

Answers (2)

trailmax
trailmax

Reputation: 35126

My guess that you do WebDeploy and it does web-config transform and adds extra section for EntityFramework for some reason (well, it tries to be helpful with EF migrations, but does more damage than good this way).

You surely don't have it locally, but deployed web.config might have extra section added. And that section is most likely at the end of the file. Can you check what is exactly in web.config on the server?

Upvotes: 0

NightOwl888
NightOwl888

Reputation: 56909

You would use the clear or remove right before they are declared (using add). So, your configuration would look something like this (assuming it is your paypal errors that are causing this - you didn't post the offending setting).

<configuration>
    <configSections>
    <!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
    <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />

    <section name="paypal" type="PayPal.Manager.SDKConfigHandler, PayPalCoreSDK" requirePermission="false" />

    </configSections>

    <paypal>
        <settings>
            <clear/>
            <add name="endpoint" value="https://api.sandbox.paypal.com"/>
            <add name="connectionTimeout" value="360000"/>
            <add name="requestRetries" value="1"/>
            <add name="ClientID" value="wefewfewDkeynC90tpFx7vfA-Pliw8uQDjv5RZ10Y_NVspuc88pUPLN6yM"/>
            <add name="ClientSecret" value="EdsfdsfdsfdzDomYG2QDHu8jhaAXj4xDZLHadvL5aRfesjwo5c81zbSpRxuE"/>
        </settings>
    </paypal>

<configuration>

Upvotes: 3

Related Questions