I have been researching this for a while and cannot seem to figure it out.
I have a .NET SignalR Client that needs to be authenticated with ASP.NET Identity (MVC5) so that it can access SignalR hubs secured with the [Authorize] attribute.
I found the following resource (Please see Authentication options for .NET Clients / Cookie):
http://www.asp.net/signalr/overview/signalr-20/security/hub-authorization
However the code sample for retrieving the cookie doesn't work due to:
authCookie = response.Cookies[FormsAuthentication.FormsCookieName];
and as I am not using Forms Authentication this produces an error.
I am unsure how to change this for ASP.NET Identity?
Am I focused on the correct approach, ie. retrieving a cookie and then adding it to the Cookie Container? or should I be passing the Username and Password in headers to a Hub and authenticating somehow this way?
I did not realise how confusing it would be to authenticate using a .NET client with SignalR and Identity Framework.
Even though it is not my use case I am also tagging the question with Xamarin as I feel this might be an issue faced by Xamarin mobile developers using the SignalR .NET client also.
As I cannot seem to find any examples on the Internet, any assistance would be much appreciated. Thanks.
Just change this
var authCookie = response.Cookies[FormsAuthentication.FormsCookieName];
to
var authCookie = response.Cookies[".AspNet.ApplicationCookie"];
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With