ASP.NET MVC Action is Called Twice

Not returning false or preventing the default action on the event in a JavaScript click handler on a link that makes the call via AJAX. In this case, it will also take the default action of the link (i.e., a non-AJAX post to the same URL).

Ex.

<%= Html.ActionLink( "action", "controller" ) %>


$(function() {
   $('a').on('click', function(e) {
      // solve with "e.preventDefault();" here
      var href = $(this).attr('href');
      $.get(href, function() { ... });
      // or solve with "return false;" here to prevent double request
   });
}):

Leave a Comment