title: Best Practice for Use HttpClient
body: <p>I'm using HttpClient to make request to WebApi. </p>
  
  <p>I have written this code</p>
  
  <pre><code> public async Task&lt;string&gt; ExecuteGetHttp(string url, Dictionary&lt;string, string&gt; headers = null)
          {
              using (var client = new HttpClient())
              {
                  client.BaseAddress = new Uri(url);
                  client.DefaultRequestHeaders.Accept.Clear();
                  client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
                  if (headers != null)
                  {
                      foreach (var header in headers)
                      {
                          client.DefaultRequestHeaders.Add(header.Key, header.Value);
                      }
                  }
                  var response = await client.GetAsync(url);
                  response.EnsureSuccessStatusCode();
                  return await response.Content.ReadAsStringAsync();
              } 
          }
  </code></pre>
  
  <p>Now I'm calling this method from my action.</p>
  
  <pre><code>public async Task&lt;ActionResult&gt; Index()
          {
              try
              {
                  RestWebRequest RestWebRequest = new RestWebRequest();
                  Dictionary&lt;string, string&gt; headers = new Dictionary&lt;string, string&gt;();
                  headers.Add("Authorization", "bearer _AxE9GWUO__8iIGS8stK1GrXuCXuz0xJ8Ba_nR1W2AhhOWy9r98e2_YquUmjFsAv1RcI94ROKEbiEjFVGmoiqmUU7qB5_Rjw1Z3FWMtzEc8BeM60WuIuF2fx_Y2FNTE_6XRhXce75MNf4-i0HbygnClzqDdrdG_B0hK6u2H7rtpBFV0BYZIUqFuJpkg4Aus85P8_Rd2KTCC5o6mHPiGxRl_yGFFTTL4_GvSuBQH39RoMqNj94A84KlE0hm99Yk-8jY6AKdxGRoEhtW_Ddow9FKWiViSuetcegzs_YWiPMN6kBFhY401ON_M_aH067ciIu6nZ7TiIkD5GHgndMvF-dYt3nAD95uLaqX6t8MS-WS2E80h7_AuaN5JZMOEOJCUi7z3zWMD2MoSwDtiB644XdmQ5DcJUXy_lli3KKaXgArJzKj85BWTAQ8xGXz3PyVo6W8swRaY5ojfnPUmUibm4A2lkRUvu7mHLGExgZ9rOsW_BbCDJq6LlYHM1BnAQ_W6LAE5P-DxMNZj7PNmEP1LKptr2RWwYt17JPRdN27OcSvZZdam6YMlBW00Dz2T2dgWqv7LvKpVhMpOtjOSdMhDzWEcf6yqr4ldVUszCQrPfjfBBtUdN_5nqcpiWlPx3JTkx438i08Ni8ph3gDQQvl3YL5psDcdwh0-QtNjEAGvBdQCwABvkbUhnIQQo_vwA68ITg07sEYgCl7Sql5IV7bD_x-yrlHyaVNtCn9C4zVr5ALIfj0YCuCyF_l1Z1MTRE7nb");
                  var getCategories = await RestWebRequest.ExecuteGetHttp("http://localhost:53646/api/Job/GetAllCategories?isIncludeChild=true", headers);
              }
              catch (HttpRequestException ex)
              {
                  return View();
              }
    return View();
    }
  </code></pre>
  
  <p>Now It is said that <strong><a href="https://stackoverflow.com/questions/22560971/what-is-the-overhead-of-creating-a-new-httpclient-per-call-in-a-webapi-client">HttpClient has been designed to be re-used for multiple calls</a>.</strong> </p>
  
  <p>How Can I use same httpClient object for multiple calls. </p>
  
  <p>Let's suppose 
  First I'm calling</p>
  
  <p><code>http://localhost:53646/api/Job/GetAllCategories?isIncludeChild=true</code></p>
  
  <p>Now In same controller I have to call another Api with diffrent header and diffrent url.</p>
  
  <p><code>http://localhost:53646/api/Job/category/10</code></p>
  
  <p>Should I make the global object of <code>HttpClient</code> and Use the same object for all API calls. </p>