title: OperationContext.Current and HttpContext.Current are null in OWIN hosted Web API 2
body: <p>I am moving some of WCF services to the Web API. </p>
  
  <p><a href="https://msdn.microsoft.com/en-us/library/system.servicemodel.operationcontext.current(v=vs.110).aspx" rel="nofollow noreferrer">OperationContext.Current</a> is usually used in WCF for logging and staging purposes.</p>
  
  <blockquote>
    <p>But i'm seeing HttpContext.Current and OperationContext.Current as
    null.</p>
  </blockquote>
  
  <p>I have used a framework which uses OperationContext.Current to get the execution context for the current thread. So if i am opting for other ways, i have to add my custom method to the framework, which i am trying to avoid.   </p>
  
  <p>Questions:</p>
  
  <ul>
  <li>What is the workaround that i can adopt?</li>
  <li>If "adding to framework" is must, what can i use to get the current context?</li>
  </ul>
  
  <p>OWIN startup:</p>
  
  <pre><code>public class Startup
  {
      public void Configuration(IAppBuilder appBuilder)
      {
           HttpConfiguration config = new HttpConfiguration();
           HttpListener listener = (HttpListener)appBuilder.Properties["System.Net.HttpListener"];
           listener.AuthenticationSchemes = AuthenticationSchemes.IntegratedWindowsAuthentication;
  
           config.MapHttpAttributeRoutes();
           config.MapODataServiceRoute(
                  routeName: "ODataRoute",
                  routePrefix: "Data",
                  model: GetModel()
           );
           config.EnsureInitialized();
           appBuilder.UseWebApi(config);
  
      }
  }
  </code></pre>
  
  <p>Startup is called using </p>
  
  <p><code>WebApp.Start&lt;Startup&gt;(rootUri);</code></p>
  
  <p>CustomFilterAttribute.cs</p>
  
  <pre><code>public class CustomFilterAttribute : ActionFilterAttribute
  {
      public override void OnActionExecuting(HttpActionContext actionContext)
      {
          var caller = OperationContext.Current; //null
          caller = System.Web.HttpContext.Current; //null
          caller = actionContext.RequestContext.Principal.Identity as WindowsIdentity; //desired
      }
  }
  </code></pre>