title: Calling a C# async WebMethod using jQuery's $.ajax() hangs endlessly
body: <h2>The Issue:</h2>
  
  <p>I'm attempting to call a C# Web Method from jQuery to update a user's profile.</p>
  
  <p>When I implement <code>async</code> and <code>await</code>, the call is made to the Web Method <strong>but the call never completes.</strong> Chrome forever shows the response as <em>"(Pending)"</em>, and the Timing tab shows that the call is <em>"Stalled"</em>.</p>
  
  <p>Any input is greatly appreciated.</p>
  
  <hr>
  
  <h2>I've Tried:</h2>
  
  <ul>
  <li><p>Not using <code>async</code> and <code>await</code></p>
  
  <p>It works! However this entirely defeats the purpose of what I'm trying to achieve.</p></li>
  </ul>
  
  <hr>
  
  <ul>
  <li><p>Changing <code>Task&lt;bool&gt;</code> to <code>void</code>:</p>
  
  <blockquote>
    <p><em>"An asynchronous operation cannot be started at this time."</em></p>
  </blockquote>
  
  <p>(Yes, my page <em>is</em> marked <code>Async="true"</code>)</p></li>
  </ul>
  
  <hr>
  
  <ul>
  <li><p>Googling and searching SO:</p>
  
  <p>I've found a few similar questions but the resulting answers were either <em>"Just make it synchronous instead!"</em> (which entirely defeats the purpose) or they were MVC solutions that I'd rather not employ in my current project.</p></li>
  </ul>
  
  <hr>
  
  <h2>Code:</h2>
  
  <pre><code>$.ajax({
      type: "POST",
      url: "Profiles.aspx/updateProfileName",
      data: JSON.stringify({
          profileName: $input.val(),
          customer_profile_id: cp_id
      }),
      contentType: "application/json; charset=utf-8",
      dataType: "json",
      success: callSuccessful,
      error: callFailed
  });
  </code></pre>
  
  
  
  <pre><code>[WebMethod]
  public static async Task&lt;bool&gt; updateProfileName(string profileName, string customer_profile_id)
  {
      User user = (User) HttpContext.Current.Session["user"];
      if (profileName.Trim().Length == 0) return false;
      int customerProfileId = int.Parse(customer_profile_id);
  
      CustomerProfileViewModel profile = new CustomerProfileViewModel();
      profile.profile_name = profileName;
      profile.customer_profile_id = customerProfileId;
      profile.customer_id = user.customerId;
  
      bool profileUpdated =  await ExampleApi.UpdateProfile(profile);
      return profileUpdated;
  }
  </code></pre>