我正在尝试将我们的 ASP.Net MVC 应用程序从使用 Signal R1.x 迁移到 SignalR 2.x。我刚刚发现了一个问题,这肯定会给我们的前进带来问题。
我们的 Web 应用程序基于 MVC,并大量使用 HttpContext.Current.Session 变量。
当使用 SignalR 1.x 运行时,会话一切都很好。
当我们升级到 SignalR 2.x 时,Session 突然为空。
我做了一些谷歌搜索,发现了有关该问题的以下链接:
SignalR 中的 HTTPContext.Current.Session 为 null...使用 SignalR 时需要替代会话状态 https://stackoverflow.com/questions/20881591/httpcontext-current-session-is-nul-in-signalr-need-alternate-to-session-state
进一步调查发现以下信息:
http://www.asp.net/signalr/overview/signalr-20/troubleshooting-and-debugging/troubleshooting http://www.asp.net/signalr/overview/signalr-20/troubleshooting-and-debugging/troubleshooting
HTTPContext.Current.Session is null
This behavior is by design. SignalR does not support the ASP.NET session state,
since enabling the session state would break duplex messaging.
我想这将破坏大量基于 ASP .Net MVC 的应用程序。
有什么解决方法吗?
这确实是设计使然,还是在 2.x 中使用 oWin::>Startup::Configuration(){app.MapSignalR();} 启动 signalR 的结果?
如果可能的话,我想解决这个问题,如果解决方案不是那么痛苦,他们仍然会考虑转向 2.x。
想法?