How to access IOwinContext
from SignalR hub (for instance from HubCallerContext
)?
If you're on IIS, you can access the IOwinContext for the current connected client via the HubCallerContext (Context property of the Hub base 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 under System.Web, so make sure you import both of those namespaces and include the Microsoft.Owin.Host.SystemWeb assembly as a project reference.
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