title: AJAX receives 500 Internal server error when calling ASP.NET MVC Controller
body: <p>I'am receiving a 500 internal server error when trying to call a controller action using Javascript AJAX. </p>
  
  <p>I want to call a controller method when the user clicks the confirm button.</p>
  
  <p>CS Controller </p>
  
  <pre><code>[HttpPost] 
  [ValidateAntiForgeryToken]
  public ActionResult Delete(string idFb, FormCollection from)
  {
      using (var client = new HttpClient())
      {
          client.BaseAddress = new Uri(urlAPISignature);
          var deleteTask = client.DeleteAsync("api/whitepages/" + idFb);
          deleteTask.Wait();
          var result = deleteTask.Result;
          if (result.IsSuccessStatusCode)
          {
              return RedirectToAction("Index");
          }
          return RedirectToAction("Index");
      }
  }
  </code></pre>
  
  <p>CSHTML File </p>
  
  <pre><code>    columns.Add().Encoded(false).Sanitized(false).Titled("").Filterable(false).RenderValueAs(model =&gt;
             "&lt;img title=\"supprimer\" class=\"delBtnWp\" data-idEpi=\"" + model.IdFb + "\" src=\"" + @Url.Content("~/Content/Images/trash-can.png") + "\" height=\"24\" width=\"24\" alt=\"del\" /&gt;");
  .
  .
  .
  .
  &lt;script&gt;
          $(".delBtnWp").click(function () {
              var idFb = $(this).attr("data-IdFb");
              bootbox.dialog({
                  title: 'Confirmer la suppression',
                  message: 'Souhaitez-vous vraiment supprimer la ligne ?',
                  buttons: {
                      danger: {
                          label: 'Non'
                      },
                      success: {
                          label: 'Oui',
                          className: "btn-success",
                          callback: function () {
                              success ();
                          }
                      }
                  },
                  callback: function (result) {
                      if (result) {
                          $.ajax({
                              type: 'POST',
                              url: "@Url.Action("Delete", "WhitePages")",
                              data: { IdFb: idFb },
                              success: function (data) {
                                  alert("Yes");
                              }
                          });
                      }
                  }
              });
          });
  &lt;/script&gt;
  </code></pre>
  
  <p>The compiler is not even reaching the controller action.</p>