How do I get IOwinContext from SignalR Hub?

How do I access IOwinContext

from a SignalR hub (for example, from HubCallerContext

)?

+3


source to share


1 answer


If you are on IIS, you can access the IOwinContext for the currently connected client via the HubCallerContext (Context property of the base Hub class):

using Microsoft.AspNet.SignalR;
using System.Web;

...

Context.Request.GetHttpContext().GetOwinContext()

      



GetHttpContext is an extension under Microsoft.AspNet.SignalR and GetOwinContext is an extension in System.Web, so make sure to import both of these namespaces and include the Microsoft.Owin.Host.SystemWeb assembly as a project reference .

+4


source







All Articles