title: How to read HttpHeaders at WebService send by HttpClient
body: <p>I am trying to create a webservice. I am successfully able to send HttpClient Request to web service and getting response too.</p>
  
  <p>What I want ?</p>
  
  <p>I am sending some HttpHeaders with the POST request like userAgent, or any CustomHeader. That Header I want to read in webservice method. I don't know how to get Header list ?</p>
  
  <p>I created webservice in C#.</p>
  
  <pre><code>   public class Service1 :IService1{   
             public string putData(Stream data)
              {
          string response = string.Empty;
          try
          {
              HttpContext ctx = HttpContext.Current;
              string headerValue = ctx.Request.Headers["tej"];              
              StreamReader reader = new StreamReader(data);
              string xmlString = reader.ReadToEnd();
              StringReader sr = new StringReader(xmlString);
              MySqlCommand cmd = new MySqlCommand();
              DataSet ds = new DataSet();
  
              ds.ReadXml(sr);
              //my logic here....
  
              return "Passed";
          }
          catch (Exception ex)
          {
             return "Failed";
          }
      }
  }
  
   public interface IService1
  {
      [OperationContract]
      [WebInvoke(Method = "POST", ResponseFormat = WebMessageFormat.Xml, BodyStyle =                 WebMessageBodyStyle.Wrapped, UriTemplate = "putdata")]
      string putData(Stream sDatabase); 
  }
  </code></pre>