title: ASP.Net Web API Request URI Error
body: <p>I have an ASP.Net Web API that generally works fine.  I have a Winforms client application that does GET requests.  The client application runs on our corporate network (the API is hosted as an Azure Website).  Occasionally, and inconsistently, the HttpClient calls I make add what seem to be corporate URLs in front of my GET call.</p>
  
  <p>Example: I try to call send an HttpClient request to the following URL:     '<a href="http://xyzxyz.azurewebsites.net/api/user/1" rel="nofollow">http://xyzxyz.azurewebsites.net/api/user/1</a>'</p>
  
  <p>but the actual request made is:</p>
  
  <pre><code>'http://usgaabc1iru01/B0000D0000N0001F0000S0000R0004/http://xyzxyz.azurewebsites.net/api/user/1'
  </code></pre>
  
  <p>This obviously causes an error.</p>
  
  <p>I've asked our IT department what may be happening and they are at a loss.  Hoping someone could point me in the right direction.</p>
  
  <p>Edit:</p>
  
  <p>Here's the code I use.  First I have a static method I call everything I make a call to the API to get the HttpClient (is this awkward/bad perhaps):</p>
  
  <pre><code>public static HttpClient GetHttpClient()
      {
  
                  var credentials = new NetworkCredential(GlobalVariables.CurrentUser.UserName, GlobalVariables.CurrentUser.Password);
                  HttpClientHandler handler = new HttpClientHandler();
                  handler.UseDefaultCredentials = false;
                  handler.Credentials = credentials;
  
                  HttpClient client = new HttpClient(handler);
                  client.BaseAddress = new Uri(PublicClasses.GlobalVariables.BaseUriString);
                  client.DefaultRequestHeaders.Accept.Add(
                          new MediaTypeWithQualityHeaderValue("application/json"));
                  GlobalVariables.CredentialedHttpClient = client;
              }
              return GlobalVariables.CredentialedHttpClient;
          }
     }
  </code></pre>
  
  <p>Here's a simple GET call I use:</p>
  
  <pre><code>public static List&lt;Project&gt; GetAllProjects()
      {
          try
          {
  
              HttpClient client = GetHttpClient();
              HttpResponseMessage response = client.GetAsync("api/project").Result;  // Blocking call!
              if (response.IsSuccessStatusCode)
              {
                  var projects = response.Content.ReadAsAsync&lt;IEnumerable&lt;Project&gt;&gt;().Result;
                  return (List&lt;Project&gt;)projects; 
              }
              else
              {
                  Console.WriteLine("{0} ({1})", (int)response.StatusCode, response.ReasonPhrase);
                  return null;
              }
  
          }
          catch (Exception)
          {
  
              throw;
          }
      }
  </code></pre>