Search code examples
c#owinazure-worker-roles

HttpContext.Current is null in api call when running in a azure worker role


I'm trying to use Httpcontext.Current to get to my owin context in a method (that is called by the controller), this works perfectly when running the site in IIS. The problem only exists when I run my api as a Azure worker role. Even if I add a breakpoint in my controller and try to get HttpContext.Current I still get null.

My question is: Is there something extra I need to add when using azure? Or does worker roles not support this approach?


Solution

  • I suspect that the Azure worker role uses some specific OWIN host where HttpContext.Current is not available. The HttpContext.Current is available only inside an ASP.NET host.