What is the equivalent of HttpContext.GetOwinConte

2019-07-13 13:31发布

I made a OWIN SignalR server self-hosted in a console app.

From an example that is hosting SignalR in a ASP.NET MVC application instead (in IIS), I see this line of code:

var authenticateResult = await HttpContext.GetOwinContext().Authentication.AuthenticateAsync("ExternalCookie");

I do not have access to HttpContext in my console app (and do not want to reference the System.Web.Mvc assembly if possible). What would be the equivalent of HttpContext.GetOwinContext() in my SignalR hub class?

1条回答
放我归山
2楼-- · 2019-07-13 14:07

Nuget package:

https://www.nuget.org/packages/OwinRequestScopeContext/

In Configuration:

app.UseRequestScopeContext();

In hub:

new Microsoft.Owin.OwinContext(OwinRequestScopeContext.Current.Environment)
查看更多
登录 后发表回答