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?

Windows development | Internet Information Services
Windows for business | Windows Server | User experience | Other
Developer technologies | ASP.NET | Other
{count} votes

Answer accepted by question author
  1. Sam Wu-MSFT 7,566 Reputation points Microsoft External Staff
    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 6,037 Reputation points
    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

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.