»
S
I
D
E
B
A
R
«
ASP.NET MVC Controller action being called twice issues
July 11th, 2010 by evereq

Your ASP.NET MVC controller action (same action) called multiply times?

Here is a main “check” list for you:

  • Check that you don’t have any image or another elements in View with empty src attribute (<img src=”" /> for example) or have src attribute referencing something that no longer existed. You better check directly in browser “Page Source”, than in View itself due to possibility of some “dynamic” issues when View rendered. Ones you found such empty element in page html source its usually trivial to found same element in your view and fix issue.
  • Check that you don’t have any ajax calls referencing an empty URL (browsers will interpret such empty url as current page and request current page again make controller action execute few times)
  • You forgot to return “false” from JavaScript click event handler for link or button that makes AJAX call. If you forget “return false” browser simply made default action of the link – regular, non AJAX, call to same page)
  • Sometimes Firebug and YSlow Firefox (FF) plugins can cause such issues… Just temporary disable them in FF or check in different browser.

Know another reason? Let me know!


  • Roman Bugaev

    Same error if you use jquery.validate.unobtrusive.js

  • shaz n jam

    Yes I have used Internet explorer and used MVC controller. It is working fine. Thanks.

    Ahsima
    http://www.m6.net

  • Taylor

    Hmmm…I haven’t dug into this deeply yet. And I don’t know if this is happening in production yet. But…

    1. When debugging on my workstation
    2. ONLY from Firefox (with Firebug disabled)
    3. And ONLY when there is a space character (%20) in the URL, like so: http://localhost:1873/results/CA/Irvine/crossword%20puzzle

    IE8 and Chrome will both process this page without causing a second firing of the controller action. So I think I can rule out all of the image/href/css/js ideas. It’s the same page.
    I don’t know if the second request is actually coming from FF. I have seen one other person post a problem where they verified that the issue seems to be within the web server. Meaning no second request is made by the browser.

  • http://blog.evereq.com EvereQ

    Sent from my iPad

  • Contact

    I had a similar problem when I tried to have a partial view with an ajax form. I had to move the ajax form out of the partial view and on to the main page to get the double calls to the controller action to go away.

»  Substance: WordPress   »  Style: Ahren Ahimsa
© Copyright 2008–2010 EvereQ.com All rights reserved. Logos, company names used here if any are only for reference purposes and they may be respective owners right or trademarks.