WebSep 10, 2016 · 2 Answers Sorted by: 6 Yes, you can! First install the Microsoft.AspNetCore.Owin package. Then from anywhere you got an instance of HttpContext you can create a instance of the OwinEnvironment class with the HttpContext as parameter to the constructor. var environment = new OwinEnvironment (HttpContext); WebMar 24, 2014 · The GetOwinContext extension method is in the System.Web.Http.Owin dll which needs to be downloaded as a nuget package (The nuget package name is Microsoft.AspNet.WebApi.Owin) Install-Package Microsoft.AspNet.WebApi.Owin
c# - How to logout user in OWIN ASP.NET MVC5 - Stack Overflow
WebAug 10, 2016 · Which is being called from Startup.cs However, I receive an exception: "No owin.Environment item was found in the context". I Added all the parameters to config file as mentioned in other posts. . Above Startup … WebNov 2, 2014 · appContext = HttpContext.Current.GetOwinContext ().Get (); in OnActionExecuting instead of in the constructor, then OWIN should be ready to return the DbContext that's in use at that point. OnActionExecuting kicks in before any action methods fire, so this should be early enough to be useful. … hope health massachusetts
c# - Can
WebThere is a public property HttpContext on the Controller class, so if you inherit from that, HttpContext.GetOwinContext () works as expected. If you inherit from ApiController though, there is no such property. Therefore, HttpContext will refer to the class, which will require you to use Current to access an instance of the class. WebJul 15, 2016 · public void Configuration (IAppBuilder app) { ConfigureAuth (app); // Ensure we have our "main" access setup app.CreatePerOwinContext ( (options, owinContext) => { // Check that an instance hasn't already been added to // the OwinContext in another plugin return owinContext.Get () ?? WebDec 31, 2014 · Jan 5, 2015 at 15:02. 1. Yes it might. It doesn't affect the problem in anyway, cause I still need to access the OwinContext or RequestContext, take out the current principal, and give it to IoC to inject to the dependency being constructed. Doesn't matter if it's a IOwinContext or IPrinciple, or IUserRole. longreach house purfleet