System.ArgumentException:已添加具有相同键的项目 [英] System.ArgumentException: An item with the same key has already been added

查看:170
本文介绍了System.ArgumentException:已添加具有相同键的项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 Windows Server 2012 上配置了 ADFS,当我尝试访问 https://abc-idfs.cloudapp.net/adfs/ls/IdpInitiatedSignOn.aspx 我收到如下错误:

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)

我不明白我哪里出错了

推荐答案

从头开始设置新的 ADFS 服务器时,我多次遇到这种情况.在我的例子中,我有设置服务器的 powershell 代码,但是在脚本运行后它总是给我这个错误,所以我知道它是配置中的东西,而不是 ADFS 本​​身.

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.

所以最后问题出在我的情况:声明提供者标识符需要有 https://而不是 http://

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

要检查此设置的值,请​​打开 AD FS 管理 UI,展开信任关系,选择声明提供者信任,选择您的声明提供者并右键单击并选择属性,然后转到标识符选项卡并查看声明提供者标识符- 如果此值没有 https://并且您正在使用证书来处理服务通信,您将在日志中获得事件 ID 364,并带有此确切消息.

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 的原因有很多,不仅仅是我在这里提到的一个,但这个问题非常简单,很容易被忽视.希望这对某人有所帮助.

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.

这篇关于System.ArgumentException:已添加具有相同键的项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆