本文介绍了BootstrapContext是ClaimsIdentity空的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经创建了.NET 4.5新的ASP.NET MVC应用程序。我已成功地建立了认证与STS。认证流程是工作的罚款,我能够得到ClaimsIdentity,包含所需索赔,在Thread.CurrentPrincipal中。

I have created a new ASP.NET MVC application with .NET 4.5. I have successfully set up authentication with an STS. The authentication flow is working fine and I am able to get the ClaimsIdentity, containing the desired claims, on Thread.CurrentPrincipal.

现在我需要引导标记,以确保我的服务层的调用。我已经设置了saveBootstrapContext为true identityConfiguration元素。

Now I need the bootstrap token to secure the calls to my service layer. I have set the saveBootstrapContext to true on the identityConfiguration element.

<system.identityModel>
    <identityConfiguration saveBootstrapContext="true">

然而,在ClaimsIdentity的BootstrapContext属性总是空。

However, the BootstrapContext property on the ClaimsIdentity is always null.

var identity = Thread.CurrentPrincipal.Identity as ClaimsIdentity;
var context = identity.BootstrapContext; // context is always null

我缺少什么吗?这应该是简单的:(

Am I missing anything here? This was supposed to be straightforward :(

----------- ------------解决

后,我重新启动我的系统,此问题已得到解决。需要注意的是它的一个IISRESET后并没有解决。后来,我改变了配置中使用Microsoft.IdentityModel而不是System.IdentityModel。我能瑞普此行为。另一个重新启动后,我能再次获得引导标记。
任何人都遇到同样的行为?

This issue is resolved after I rebooted my system. Note that it did not resolved after an iisreset. Later I changed the configuration to use Microsoft.IdentityModel instead of System.IdentityModel. I was able to repro this behavior. After another reboot, I was able to get the bootstrap token once again.Anyone else experiencing same behavior?

推荐答案

我在IIS防爆preSS托管时,就遇到了这个问题。事实证明,这个问题是我的浏览器 - 我还没有关闭了我所有的浏览器窗口或清除饼干,所以SessionSecurityToken没有被使用新设置重新创建,即使服务器已经重新启动(现有FedAuth的cookie仍然还在从浏览器发送)。

I ran into this problem when hosting in IIS Express. It turns out that the issue was my browser - I had not closed all of my browser windows or cleared cookies, so the SessionSecurityToken was not being recreated with the new setting, even though the server had been restarted (the existing FedAuth cookie was still being sent from the browser).

在我被迫重新认证通过关闭所有浏览器窗口,重新启动浏览器并再次执行我的要求下,BootstrapContext是present。

Once I forced a re-authentication by closing all browser windows, restarting the browser and performing my request again, the BootstrapContext was present.

这篇关于BootstrapContext是ClaimsIdentity空的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-21 08:31