Вопрос

I upgraded my signalR version from 1.1.2 to signalR 2.0.3 following this link http://www.asp.net/signalr/overview/signalr-20/getting-started-with-signalr-20/upgrading-signalr-1x-projects-to-20 and everything works ok, but WebMatrix.WebData.WebSecurity.CurrentUserId has a null value when I call any method of a hub in the server.

This is my startup file:

using Microsoft.Owin;
using Owin;
using Microsoft.AspNet.SignalR;

[assembly: OwinStartup(typeof(SignalRChat.Startup))]
namespace SignalRChat
{

    public class Startup
    {
        public void Configuration(IAppBuilder app)
        {
            app.MapSignalR(new HubConfiguration
                {
                    Resolver = GlobalHost.DependencyResolver
                });
            GlobalHost.HubPipeline.RequireAuthentication();
        }
    }
}

And this is one of my hubs:

[Authorize]
    public class MessageConnection : Hub
    {
      ...
      public Task SendMessage(int destinationId, string msg)
        {
            int userId = WebMatrix.WebData.WebSecurity.CurrentUserId; //throwing exception              ...
        }
    }

This piece of code was working before I upgraded SignalR to V 2.0.3 so I do not know what Im missing.

Это было полезно?

Решение

The Owin version (2.0.0) used in the latests SignalR (> 2.0.0) is not compatible with Webmatrix.WebData.WebSecurity. Instead, it can be replaced with AspNet.Identity.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top