通过WIFI认证后User.Identity.Name为空

2024-01-21

我正在使用 WIFI 登录我的应用程序。一切似乎都很好(日志记录、重定向到网站等),但是当我尝试使用User.Identity.Name在我的鳕鱼异常被抛出-User为空。有什么想法我做错了吗?我在 VS 2012 上工作。web.config 中生成的部分如下所示:

  <system.identityModel>
    <identityConfiguration>
      <audienceUris>
        <add value="http://xxx/" />
      </audienceUris>     
      <issuerNameRegistry type="System.IdentityModel.Tokens.ConfigurationBasedIssuerNameRegistry, System.IdentityModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
        <trustedIssuers>
          <add thumbprint="yyyy" name="https://zzz" />
        </trustedIssuers>
      </issuerNameRegistry>
    </identityConfiguration>
  </system.identityModel>

and:

  <system.identityModel.services>
    <federationConfiguration>
      <cookieHandler requireSsl="false" />
      <wsFederation passiveRedirectEnabled="true" issuer="https://zzz/Secure/FederatedLogin.ashx" realm="http://xxx" requireHttps="false" />          
    </federationConfiguration>        
  </system.identityModel.services>

使用 WIF 时,您应该使用 Thread.CurrentPrincipal.Identity.Name 而不是 User.Identity.Name。

在这里阅读更多内容:http://msdn.microsoft.com/en-us/magazine/ff872350.aspx http://msdn.microsoft.com/en-us/magazine/ff872350.aspx了解有关 Windows Identity Foundation 的更多信息

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

通过WIFI认证后User.Identity.Name为空 的相关文章

随机推荐