Signalr在从一个页面导航到另一个页面时注销用户

时间:2013-12-30 20:50:43

标签: c# signalr .net-4.5

我已经设置了健康监控,我收到以下错误。

在Safari浏览器中,我收到下面的Signalr错误,我在其他浏览器中没有收到此错误。

有些奇怪的是,当我从一个页面导航到下一个页面时,这个错误实际上会退出用户并将其发送到登录页面,这是在它们之后登录。

任何人都知道为什么会发生这种情况?

    ** Application Information **
---------------
Application domain: /LM/W3SVC/15/ROOT-1-130329090058437500
Trust level: Full
Application Virtual Path: /
Application Path: C:\inetpub\wwwroot\alumcloud.com\ Machine name: AFBS-WEB1


** Events **
---------------
Event code: 3005
Event message: An unhandled exception has occurred.
Event time: 12/30/2013 2:32:24 PM
Event time (UTC): 12/30/2013 8:32:24 PM
Event ID: a243cb6cf5e24be8bfa0d1bec6e77812 Event sequence: 211 Event occurrence: 2 Event detail code: 0

Process information:
    Process ID: 924
    Process name: w3wp.exe
    Account name: NT AUTHORITY\NETWORK SERVICE

Exception information:
    Exception type: System.InvalidOperationException
    Exception message: Unrecognized user identity.  The user identity cannot change during an active SignalR connection.

Request information:
    Request URL: http://www.alumcloud.com/signalr/abort?transport=serverSentEvents&connectionToken=xHLBS1B7LGOjUWkVos29QlnBuMwBfTg%2BNQuEDmrhy%2BADr45Yw0iDIHCh1nX8omumVA%2F1eFje774jLVE%2BOId8ab4cJJ3r1hZ8DGlq23yA0WsGk0biYy7JYmnxM2hqu2cw&connectionData=%5B%7B%22name%22%3A%22alumchathub%22%7D%5D
    Request path: /signalr/abort
    User host address: 71.244.XXX.XXX
    User: XXXXXXXXXXXX
    Is authenticated: True
    Authentication Type: Forms
    Thread account name: NT AUTHORITY\NETWORK SERVICE

Thread information:
    Thread ID: 22
    Thread account name: NT AUTHORITY\NETWORK SERVICE
    Is impersonating: False
    Stack trace:    at Microsoft.AspNet.SignalR.PersistentConnection.GetConnectionId(HostContext context, String connectionToken)
   at Microsoft.AspNet.SignalR.PersistentConnection.ProcessRequest(HostContext context)
   at Microsoft.AspNet.SignalR.Hubs.HubDispatcher.ProcessRequest(HostContext context)
   at Microsoft.AspNet.SignalR.PersistentConnection.ProcessRequest(IDictionary`2 environment)
   at Microsoft.Owin.Mapping.MapMiddleware.<Invoke>d__0.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at Microsoft.Owin.Host.SystemWeb.IntegratedPipeline.IntegratedPipelineContext.EndFinalWork(IAsyncResult ar)
   at System.Web.HttpApplication.AsyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
   at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)

1 个答案:

答案 0 :(得分:0)

由于请求/ signalr / abort?...,似乎必须调用connection.stop。这可能是因为您直接调用了connection.stop,或者因为当用户使用SignalR连接导航离开页面时,SignalR间接调用了connection.stop

异常消息(“无法识别的用户身份。用户身份在活动的SignalR连接期间无法更改。”)表示用户的IIdentity在SignalR连接开始和停止之间发生了变化。

这可能由于多种原因而发生,可能最常见的是ASP.NET表单auth cookie到期导致用户的身份变得未经身份验证。其他原因可能是用户在SignalR连接正在进行时注销,登录或切换用户。

SignalR不允许用户的IIdentity在正在进行的连接期间进行更改,以帮助防止CSRF攻击。

对/ signalr / abort的请求?...是SignalR客户端发出的Ajax请求。 SignalR客户端不会根据中止请求的响应采取任何操作,因此我不希望失败的中止导致任何类型的重定向。