Context.User是空的Signalr 2.0集线器 [英] Context.User is null in a Signalr 2.0 Hub

查看:203
本文介绍了Context.User是空的Signalr 2.0集线器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用VS 2013防爆preSS和标准MVC5模板来创建一个新的干净的应用程序。身份验证已启用,我可以登录到该网站就好了。我可以看到用户上下文在我的控制器,但是当我加入Signalr我不能得到的集线器来注册认证有发生。

I'm using VS 2013 Express and the standard MVC5 template to create a new clean app. Authentication is enabled and I can log into the site just fine. I can see the user context in my controllers, but when I add Signalr I can't get the Hubs to register that authentication has take place.

Context.User轮毂为空。使用Signalr 2.0.2及所有相关OWIN包。

Context.User in the hub is null. Using Signalr 2.0.2 and all related OWIN packages.

推荐答案

的决议,该方案是非常简单的。在我的启动类,我在错误的顺序code。

The resolution to the program was very simple. In my startup class I had the code in the wrong order.

这是我有什么,当它不工作:

This is what I had when it wasn't working:

    app.MapSignalR();
    ConfigureAuth(app);

不过,这是正确的顺序与身份验证Signalr工作:

However, this is the correct order to have Signalr work with authentication:

    ConfigureAuth(app);
    app.MapSignalR();

这可能是一个没有脑子的大部分,但我认为这是一个容易犯的错误。

This may be a no-brainer for most, but I think it's an easy mistake to make.

这篇关于Context.User是空的Signalr 2.0集线器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆