【问题标题】:SignalR OnDisconnected method when the window is closed Identity.Name is empty窗口关闭时的 SignalR OnDisconnected 方法 Identity.Name 为空
【发布时间】:2014-02-07 03:24:09
【问题描述】:

我是 SignalR 的新手,我明白为什么当我关闭窗口时,会调用 OnDisconnected,而 Identity.Name 为空?

以及索赔等...

override Task OnDisconnected()
{

 Context.User.Identity.Name

  var identity = (ClaimsPrincipal)Thread.CurrentPrincipal;
        string id = identity.Claims.Where(c => c.Type == UserInfoIdClaimType)
                                   .Select(c => c.Value).Single();

}

Altho 在这里:http://www.asp.net/signalr/overview/signalr-20/hubs-api/mapping-users-to-connections 他们使用此代码将用户映射到 id,我的意思是,如果您在用户关闭一个窗口时遇到此问题,那么您将始终在 _connections 中遇到此连接:(

任何想法,为什么会这样?

【问题讨论】:

    标签: signalr claims


    【解决方案1】:

    您可能遇到此错误:https://github.com/SignalR/SignalR/issues/2753

    它似乎是特定于 WebSocket 传输的,一旦发布就应该在 SignalR 2.0.3 中修复。

    【讨论】:

    • 哦,好的,我明白了,是的,我正在使用 websocket,好的,我 hoop 2.0.3 即将发布)
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-12-27
    • 1970-01-01
    相关资源
    最近更新 更多