我在ASP.NET Web应用程序中正确配置ValidatingIssuerNameRegistry时遇到问题。根据{{3}},我将Azure AD登录配置到我的应用程序。一切似乎工作正常,但Visual Studio 2013在配置部分为trustedIssuers提供了配置警告(蓝色下划线),所以我决定找到一个修复程序。这this article这种替代方法与VS2013配置警告对齐。但唉,它对我不起作用。当我尝试运行它时,IIS Express会出错。
关于我混淆了什么的任何想法?我猜测.NET 4.5 / 4.0有一个版本问题或者那种性质,但我找不到它。
这不起作用...... (服务器错误:WIF10112:'issuerNameRegistry'中唯一支持的元素是'权限'。找到元素'trustedIssuers'。)注意:错误页面报告的底部:
版本信息:Microsoft .NET Framework版本:4.0.30319; ASP.NET版本:4.0.30319.34009
<issuerNameRegistry type="System.IdentityModel.Tokens.ValidatingIssuerNameRegistry, System.IdentityModel.Tokens.ValidatingIssuerNameRegistry">
<trustedIssuers>
<add name="[MYNAME]" thumbprint="[MYTHUMB]"/>
</trustedIssuers>
</issuerNameRegistry>
这确实有效,但会给出编译时警告(预期'trustedIssuers')......
<issuerNameRegistry type="System.IdentityModel.Tokens.ValidatingIssuerNameRegistry, System.IdentityModel.Tokens.ValidatingIssuerNameRegistry">
<authority name="MYNAME">
<keys>
<add thumbprint="MYTHUMB" />
</keys>
<validIssuers>
<add name="MYNAME" />
</validIssuers>
</authority>
</issuerNameRegistry>
答案 0 :(得分:2)
据我所知,Visual Studio使用XSD架构验证配置。它们通常位于C:\ Program Files(x86)\ Microsoft Visual Studio 11.0 \ Xml \ Schemas
等文件夹中ValidatingIssuerNameRegistry的架构是(http://msdn.microsoft.com/en-us/library/system.identitymodel.tokens.validatingissuernameregistry(v=vs.115).aspx):
<system.identityModel>
<issuerNameRegistry type='derived from ValidatingIssuerNameRegistry'>
<authority name='someFriendlyName'>
<keys>
<add thumbprint='caseInsensitiveString'/>
<add symmetricKey='Base64Encoded bytes' />
</keys>
<validIssuers>
<add name='issuer1'/>
<add name='issuer2'/>
</validIssuers>
</authority>
</issuerNameRegistry>
</system.identityModel>
ConfigurationBasedIssuerNameRegistry的架构是(http://msdn.microsoft.com/en-us/library/system.identitymodel.tokens.configurationbasedissuernameregistry(v=vs.110).aspx):
<system.identityModel>
<identityConfiguration>
<issuerNameRegistry type="System.IdentityModel.Tokens.ConfigurationBasedIssuerNameRegistry, System.IdentityModel">
<trustedIssuers>
<add thumbprint="thumbprint" name="name" />
</trustedIssuers>
</issuerNameRegistry>
</identityConfiguration>
Visual Studio可能只使用一个或另一个引用的XSD文件。找到它的最简单方法是在XSD文件中搜索字符串vs:help =“configuration / system.identityModel / issuerNameRegistry”
如果您愿意,可以更新架构,以便不再获得带蓝色下划线的文本。我只使用Visual Studio 2012,因此无法确认这对您有用。
答案 1 :(得分:1)
我想我找出了问题,但我不确定原因。出于某种原因,系统必须选择以前版本的“System.IdentityModel.Tokens.ValidatingIssuerNameRegistry”。如果你能解释原因,我很乐意将你标记为答案。
<issuerNameRegistry type="System.IdentityModel.Tokens.ValidatingIssuerNameRegistry, System.IdentityModel.Tokens.ValidatingIssuerNameRegistry">
<trustedIssuers>
<add name="[MYNAME]" thumbprint="[MYTHUMB]"/>
</trustedIssuers>
</issuerNameRegistry>
应该......
<issuerNameRegistry type="System.IdentityModel.Tokens.ConfigurationBasedIssuerNameRegistry, System.IdentityModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<trustedIssuers>
<add name="[MYNAME]" thumbprint="[MYTHUMB]"/>
</trustedIssuers>
</issuerNameRegistry>