title: C# An object reference is required for the non-static field, method, or property 'HttpContext.Request'
body: <p>I am trying create a common factory class to call WCF and to inject some headers. In this class I am trying to read the HTTP Header properties.   </p>
  
  <pre><code>    using System.ServiceModel;
      using System.ServiceModel.Channels;
      using ServiceReference;
      using Microsoft.AspNetCore.Http;
  namespace Service
  {
       public class ServiceFactory
          {
  
              public static ServiceClient Create()
              {
                  ServiceProxy service = new ServiceProxy();
                  string userName = HttpContext.Request.Headers["AUTH_USERNAME"];
                  string authenricationType = HttpContext.Request.Headers["AUTH_TYPE"];
  
                  using (new System.ServiceModel.OperationContextScope((System.ServiceModel.IClientChannel)service.InnerChannel))
                  {          
                      HttpRequestMessageProperty requestMessage = new HttpRequestMessageProperty();
                      requestMessage.Headers["AUTH_USERNAME"] = userName;
                      OperationContext.Current.OutgoingMessageProperties[HttpRequestMessageProperty.Name] = requestMessage;
  
                      requestMessage.Headers["AUTH_TYPE"] = authenricationType;
                      OperationContext.Current.OutgoingMessageProperties[HttpRequestMessageProperty.Name] = requestMessage;
                  }
                  return service;
              }       
          }
  }
  </code></pre>
  
  <p>But I get a compile error as <strong>"An object reference is required for the non-static field, method, or property 'HttpContext.Request'</strong>. Since I am not calling from a Static method or a class how this could happen. Any help would be highly appreciated.</p>
  
  <p>Thank you.</p>