ASP.NET MVC Action is Called Twice

Very late but I found that having

<img id="myLogo" src="#"/> 

caused this to make it do the call again. Hope this helps someone, the reason I am not sure.

Found solution here. http://skonakanchi.blogspot.com/2011/09/action-method-calling-twice-in-aspnet.html


I had a similar issue. The issue was caused by this line in my _Layout.cshtml file:

<link rel="shortcut icon" href="">

After removing the above line, my actions are called once.


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
   });
}):

Tags:

Asp.Net Mvc