System.ArgumentException: An item with the same key has already been added

|▌冷眼眸甩不掉的悲伤 提交于 2021-02-10 03:23:14

问题


I configured ADFS on Windows Server 2012 and when i tried to access https://abc-idfs.cloudapp.net/adfs/ls/IdpInitiatedSignOn.aspx i got an error as:

Exception details: 
System.ArgumentException: An item with the same key has already been added.
   at System.Collections.Generic.Dictionary`2.Insert(TKey key, TValue value, Boolean add)
   at Microsoft.IdentityServer.Web.HomeRealmModule.FindApplicableRealms(ProtocolContext context, Boolean needsIDPInstance)
   at Microsoft.IdentityServer.Web.HomeRealmModule.DiscoverHomeRealm(PassiveProtocolHandler pHandler, ProtocolContext context)
   at Microsoft.IdentityServer.Web.PassiveProtocolListener.GetAuthenticationMethods(PassiveProtocolHandler protocolHandler, ProtocolContext protocolContext)
   at Microsoft.IdentityServer.Web.PassiveProtocolListener.OnGetContext(WrappedHttpListenerContext context)

I cannot understand where I am going wrong


回答1:


This happened to me a number of times when setting up new ADFS servers from scratch. In my case I have powershell code that sets up the server, but it was always giving me this error after the script ran so I knew it was something in the configuration and not with ADFS itself.

So in the end the problem was in my case: Claims provider identifier needs to have https:// instead of http://

To check the value of this setting, open up AD FS management UI, expand Trust Relationships, Select Claims Provider Trusts, select your claims provider and right click and select properties, then go to Identifiers tab and look at the Claims provider identifier - if this value does not have https:// and you are using certs to handle service communications, you will get event id 364 in your logs with this exact message.

364 can occur for a number of reasons, not just the one I am mentioning here, but this issue is so simple that it could be easily overlooked. Hope this helps someone.



来源:https://stackoverflow.com/questions/31878061/system-argumentexception-an-item-with-the-same-key-has-already-been-added

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!