English 中文(简体)
• 最佳做法
原标题:How tell if W.I.F token exists? - Best approach
  • 时间:2011-11-21 12:29:08
  •  标签:
  • wif

我正在使用Windows识别基础。 在受W.I.F.保护的场所中,有一个用户登记观点,匿名用户可以浏览。 此时此刻,我想在我的登记控制员中看到,目前存在一个W.I.F token:

我将这样做:

public bool HasWifToken(HttpContextBase httpContextBase)
        {
            var claimsIdentity = httpContextBase.User.Identity as IClaimsIdentity;
            if (claimsIdentity == null)
            {
                return false;
            }

            return claimsIdentity.Claims.Count > 0;
        }

但是,看看你是否活了吗? 非常感谢。

最佳回答

最容易做的是:

var hasWifToken = httpContextBase.User.Identity.IsAuthenticated;

如果你重新使用电算表,IsAuthenticated,将告诉你是否存在标语(即用户签名)。

问题回答

是的——你可以在身份认同感中使用IsAuthenticated.Claims.ClaimsIdentity。

Interestingly, the way it is set is very much along your approach - essentially it checks if the claims.Count > 0!





相关问题
Finding STS providers for Windows Identity Foundation

I ve had a very brief look at Windows Identity Foundation (WIF) and it looks to me like I could say that my site is going to accept logins from other sites. e.g. anyone with a gmail or LiveID account ...

Programatically configure Web App and WCF to use an STS (WIF)

Ok so I ve step up a very simple asp.net and wcf service to use and STS for authentication, however, I wonder how can i achieve the same if configuringing it programatically. I know I need to have ...

Windows Identity Foundation - Third Party Secure Token Server

I m trying to get my head around all the claims based windows identity foundation magic. Assuming I don t want to use ADFS, one thing that isn t clear to me is whether its best to roll your own STS ...

热门标签