title: How to Abort Long running Ajax Request in .net MVC 4?
body: <p>I've found several answers including <a href="https://stackoverflow.com/questions/8914728/how-do-you-cancel-an-ajax-long-running-mvc-action-client-side-in-javascript">this one</a> and also <a href="http://asprogramming.blogspot.com.tr/2012/02/ajax-call-cancelation-in-mvc.html" rel="nofollow noreferrer">this one</a>. But for some reason <code>this.Response.IsClientConnected</code> still goes as <code>true</code>.</p>
  
  <p>Here is my Client:</p>
  
  <pre><code>&lt;div class="ajax-loader-gif-close" id="cancelBusy"&gt;Close&lt;/div&gt;
  
  @using (Html.BeginForm("List", "Visit", FormMethod.Post, new { @id = "formFilter" }))
      {
         //Some models some TextBoxFor  etc.
      }
  
  &lt;script type="text/javascript" language="javascript"&gt;
      var ajaxCallObject = null;
  
      $(document).ready(function () {
           $('form').submit(function () {
                  ajaxCallObject = $.ajax({
                      url: this.action,
                      type: this.method,
                      data: $(this).serialize(),
                      beforeSend: function () {
                          toggleBusyIndicator();
                      },
                      complete: function () {
                          toggleBusyIndicator();
                      },
                      success: function (result) {
                          //Some stuff
                      }
                  });
  
                  return false;
              });
          }
          $("#cancelBusy").click(function () {
               ajaxCallObject.abort();
          });
      });
  &lt;/script&gt;
  </code></pre>
  
  <p>Here is my Server-Side:</p>
  
  <pre><code>[HttpPost]
  public PartialViewResult List(VisitFilterViewModel model)
  {
        //IsClientConnected is ALWAYS TRUE even though I abort from client
        while (this.Response.IsClientConnected)
        {
              Thread.Sleep(500);
        }
  
        return PartialView("PartialVisitFilterList", model);
  }
  </code></pre>
  
  <p>With FireBug I see that the action is Aborted, but <code>IsClientConnected</code> is still <code>true</code>. What am I doing wrong?</p>
  
  <p>Note: If you consider removing <code>[HttpPost]</code> attribute to solve this, I've already tried and didn't work.</p>