title: How to set WebApi request header on server side
body: <p>I'm trying to use MVC to call a WebApi method according to HTTP. I need to send some info every time, like userID and app version. How can I add this info to the header? I want to do it as an ajax call, not by client side code like it is now):</p>
  
  <pre><code>      'beforeSend: function (req) {
                  req.setRequestHeader("Accept", "version=1.00,requestTime=" + new Date());
              }'
  </code></pre>
  
  <p>But on server side, I can't set RequestHeader with string
  This is my server code:</p>
  
  <pre><code> HttpClient client = new HttpClient();
   var request = new HttpRequestMessage()
          {
              RequestUri = new Uri("http://localhost/WebAPIDemo/FilterAttribute-MVC"),
              Method = HttpMethod.Get,
          };
  
          request.Headers.Accept.Add(***);
          //request.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
          List&lt;OfficeSupply&gt; os=new List&lt;OfficeSupply&gt;();
          var task = client.SendAsync(request)
              .ContinueWith((taskwithmsg) =&gt;
              {
                  var response = taskwithmsg.Result;
  
                  var jsonTask = response.Content.ReadAsAsync&lt;List&lt;OfficeSupply&gt;&gt;();
                  jsonTask.Wait();
                  var jsonObject = jsonTask.Result;
                  os = jsonObject.ToList();
              });
          task.Wait();
  </code></pre>
  
  <p><code>***</code> needs to be a 'MediaTypeWithQualityHeaderValue' type value,but I just want to set it to custom, like the ajax call. How should I do it?</p>
  
  <p>Also, I want to change Header Authorization parameter, but this code:</p>
  
  <pre><code> 'client.DefaultRequestHeaders.Add("Authorization", "12345");' 
  </code></pre>
  
  <p>did not work and </p>
  
  <pre><code>  request.Headers.Authorization.Parameter
  </code></pre>
  
  <p>told me it is read-only.</p>
  
  <p>How do I set it on the server side before sending?</p>