5

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.

1
  • and how you get it at all? i put authorize, then using MVC5, i log in, it still tell me unauthorize... also there is no code preview, for first part which uses AuthorizeAttribute, to tell what to do other than putting this attribute, ... to be able to authorize or unauthorize a client. Commented Jun 14, 2015 at 5:46

1 Answer 1

1

Just change this

var authCookie = response.Cookies[FormsAuthentication.FormsCookieName];

to

var authCookie = response.Cookies[".AspNet.ApplicationCookie"];

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.