What is the equivalent of HttpContext.GetOwinContext() from a Hub?

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-24 03:50:58

问题


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:


Nuget package:

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

In Configuration:

app.UseRequestScopeContext();

In hub:

new Microsoft.Owin.OwinContext(OwinRequestScopeContext.Current.Environment)


来源:https://stackoverflow.com/questions/38808214/what-is-the-equivalent-of-httpcontext-getowincontext-from-a-hub

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!