Cannot add duplicate collection entry of type 'add' with unique key attribute 'test4' set to 'tagsmodule'

xibiliyaha 40 Reputation points
2023-05-20T20:20:15.69+00:00

I am deploying my asp.net application in windows server and got this error.

Config Error: Cannot add duplicate collection entry of type 'add' with unique key attribute 'test4' set to 'tagsmodule'.

Any idea how to solve this error?

Internet Information Services
ASP.NET
ASP.NET
A set of technologies in the .NET Framework for building web applications and XML web services.
3,410 questions
Windows Server
Windows Server
A family of Microsoft server operating systems that support enterprise-level management, data storage, applications, and communications.
12,596 questions
{count} votes

Accepted answer
  1. Sam Wu-MSFT 7,286 Reputation points Microsoft Vendor
    2023-05-21T03:29:59.3266667+00:00

    @xibiliyaha

    Since the error message mentions a duplicate record, check the web.config for identical definitions:

    1. Enable Failed Request Tracing
    2. Add a rule
    3. If the issue occurs, check web.config file. Are there identical Failed Request Tracing rules?

    If there are no duplicates, check the rules in tracing module at all application, site, and server levels in IIS Manager. Make sure there are no conflicting rules.

    If the issue still persists, add the line below into web.config. It will remove all existing rules to prevent duplication.

    <remove path="*" />
    

    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments

1 additional answer

Sort by: Most helpful
  1. Lex Li (Microsoft) 5,312 Reputation points Microsoft Employee
    2023-05-20T23:38:37.3366667+00:00

    If you configure a collection in web.config, the best way is to add a remove tag in front,

    <configuration>
      <...>
        <...>
          <remove test4="tagsmodule" />
          <add test4="tagsmodule" ... />
        </...>
      </...>
    </configuration>
    
    
    0 comments No comments