title: Function not returning data when called by JavaScript
body: <p>Whilst debugging, using Unit Tests, the function returns the expected data, however when the same function is called from JavaScript, the function is hit but then doesn't return any data. </p>
  
  <p>This function that I'm calling that's in the dll is hanging, but only when it is called by a function that has been called by a JS request, why would this be?</p>
  
  <p>EDIT:</p>
  
  <p>As in comments, my best guess is that it is something to do with a thread being in use, but I don't know, as the function itself is working, just not when called from a C# function called by AJAX.</p>
  
  <p>AJAX call :</p>
  
  <pre><code>function getOnHoldTickets() {
      $.ajax({
          type: "GET",
          url: "/cloud/getTicketCount/",
          dataType: "json",
          success: function (data) {
              onHoldHandler(data);
          },
          failure: function () {
              alert("getOnHoldTickets failled");
          }
      });
  }
  </code></pre>
  
  <p>Controller :</p>
  
  <pre><code>// api gets hit from the JS call
  [Route("cloud/getTicketCount")]
  public List&lt;UberTicket&gt; getTicketCount()
  {
      var tickets = Dashboard.getTODTickets("On Hold"); 
      return tickets;
  }
  
  
  [TestMethod] // calls the same method as JS
  public void supportTicketTesting()
  {
      var openTickets = Dashboard.getTODTickets("On Hold");
      var check = openTickets != null;
  }
  
  // method calling the dll
  public static List&lt;UberTicket&gt; getTODTickets(string type)
  {
      var tickets = UberAPI.getTODTickets(type);
      return tickets;
  }
  </code></pre>
  
  <p>DLL Method:</p>
  
  <pre><code>// the method within the dll that's hanging when called by a function invoked by JS
  public static async Task&lt;RootObjectClass&lt;T&gt;&gt; genericGet&lt;T&gt;(string function, string parameters)
  {
      try
      {
          // create credentials to pass to httpClient
          var httpClientCredentials = new HttpClientHandler()
          {
              Credentials = new NetworkCredential(uberAPIUser, uberAPIPass)
          };
  
          using (var client = new HttpClient(httpClientCredentials))
          {
              // unsure if the headers are being passed in correctly - getting good response though
              client.DefaultRequestHeaders.TryAddWithoutValidation("Content-Type", "application/x-www-form-urlencoded");
              var response = await client.GetAsync(ubersmithURL + function + parameters);
              var result = await response.Content.ReadAsStringAsync();
              // remove nulls from json
              result = Regex.Replace(result, ":null,", ":\"\",");
              var ms = new MemoryStream(Encoding.UTF8.GetBytes(result));
              var success = JsonConvert.DeserializeObject&lt;RootObjectClass&lt;T&gt;&gt;(result);
              return success;
          }
      }
      catch(Exception ex)
      {
          // log error
      }
      return new RootObjectClass&lt;T&gt;();
  }
  </code></pre>