There is a problem in my production code when Request.GetOwinContext () always returns null.
I am setting up a small WebAPI test controller to try to isolate the problem:
public class TestController : ApiController { [HttpGet] public async Task<IHttpActionResult> GetAsyncContext(string provider) { if (HttpContext.Current.GetOwinContext() == null) return this.BadRequest("No HttpContext.Current Owin Context"); if (Request.GetOwinContext() == null) return this.BadRequest("No Owin Context"); return this.Ok(); } [HttpGet] public IHttpActionResult GetContext(string provider) { if (HttpContext.Current.GetOwinContext() == null) return this.BadRequest("No HttpContext.Current Owin Context"); if (Request.GetOwinContext() == null) return this.BadRequest("No Owin Context"); return this.Ok(); } }
At first I thought that this might have something to do with the action method that is executed asynchronously, but after doing the above it turns out that in both versions of Request.GetOwinContext () returns null.
I am using Microsoft.AspNet.WebApi.Owin.5.1.1 (which seems to be determined by the GetOwinContext () extension method).
Any ideas on what's going on here ???
asp.net-web-api owin
Jtech
source share