SignalR Context.User.Name returns empty

ぃ、小莉子 提交于 2019-12-07 17:20:25

问题


Whenever I try to access Context.User.Identity from a Hub, the user details are always empty.

Note: Context.User does not return null, the properties are just empty:

I've taken a look at a multitude of questions on SO similar to this, but all of them seem to be asking why the Context.User is null, and the answer is to move app.MapSignalR(); below ConfigureAuth();, as I have done:

    public void Configuration(IAppBuilder app)
    {
        ConfigureAuth(app);
        app.MapSignalR();
    }

The HttpContext.Current.User also returns empty, but again, only from within a Hub. If I call it from any other Controller, I get the currently logged in user details.

Finally, I also find it disturbing that HttpContext.Current.User.IsAuthenticated is false, yet the user can still access the function. (See the Authorize attribute in the screenshot above.)

Is anybody able to shed some light as to why my user is empty?

All help is greatly appreciated.


回答1:


Set anoynomous to false and windows authentication to true



来源:https://stackoverflow.com/questions/34709307/signalr-context-user-name-returns-empty

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!