问题
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