简体   繁体   English

SignalR ASP.NET MVC5身份

[英]SignalR ASP.NET MVC5 Identity

i am trying to make SignalR work using ASP.NET Identity. 我正在尝试使用ASP.NET身份使SignalR工作。 The code is very simple, where we create a new MVC5 Web Application, enable Google Account External, login with google account and make request to the Hub recognize the user by calling: 代码非常简单,我们创建一个新的MVC5 Web应用程序,启用Google帐户外部,使用Google帐户登录并向Hub请求通过调用以下方式识别用户:

Context.User.Identity Context.User.Identity

Anyway, this is always returning null and it seems the client proxy is not able to send the external cookie. 无论如何,这总是返回null,似乎客户端代理无法发送外部cookie。

The only workaround is doing the same steps as stated here: 唯一的解决方法是执行与此处所述相同的步骤:

http://gobbe.net/2013/06/13/use-the-asp-net-membership-in-a-signalr-chat-with-an-asp-net-mvc-4-application/ http://gobbe.net/2013/06/13/use-the-asp-net-membership-in-a-signalr-chat-with-an-asp-net-mvc-4-application/

The workaround works, but I would prefer to use another solution. 解决方法有效,但我更愿意使用其他解决方案。 I also checked https://github.com/gustavo-armenta/CookieAuthenticationSample but this is not using external authentication. 我还检查了https://github.com/gustavo-armenta/CookieAuthenticationSample但这不使用外部身份验证。

Do you have any other ideas on how the Hub can recognize the external authentication schema of ASP.NET Identity? 您对Hub如何识别ASP.NET身份的外部身份验证模式有任何其他想法吗?

Thanks 谢谢

Ok. 好。 After hours of searching I went to jabbr online support and davidfowl helped out. 经过几个小时的搜索,我去了jabbr在线支持,davidfowl得到了帮助。 The problem was the ordering of the calls on the Startup class. 问题是Startup类上的调用顺序。 I had: 我有:

        app.MapSignalR();
        ConfigureAuth(app);

instead of: 代替:

        ConfigureAuth(app);
        app.MapSignalR();

Thanks David. 谢谢大卫。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM