Willem D'Haeseleer Willem D'Haeseleer - 1 year ago 197
ASP.NET (C#) Question

Set cookie from SignalR hub on the server

Is there anyway I can set a cookie from inside a SignalR hub, specifically the

method. I want to send a cookie with a session id.

I tried this but it didn't seem to work, it also looks awkward because I'm not sure why I need to provide a key value pair of a string and a cookie.

public override Task OnConnected()
var guid = new Guid();
Context.RequestCookies.Add("SessionID", new Microsoft.AspNet.SignalR.Cookie("SessionID", guid.ToString()));
return null;

Answer Source

I eventually decided to set the cookie from the serving MVC controller, i did not find anyway to set this from in a SignalR call.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download