views:

118

answers:

2

Hello, I'm new around so if I'm missing some info or something, please let me know and I'll provide it. I've already looked for informationg regarding this error, but I haven't found anything relevant yet. So, here's the deal.. Some of my controllers actions are being called twice, and I've just noticed that when I was wondering why was I sending SOME mails twice (the application I've got has an email client incorporated).. and only then after logging what was I doing I noticed the controller gets called twice... By the way, this only happens when I called the action from a link outside the application or by typing the url. If I'm not making myself clear or I'm missing something, please do post here anyway so I can add more info..

Thanks in advance!

+1  A: 

Without seeing the actual application code, I'm left to simply guess - however, I know of at least one semi-famous bug in this arena, see http://blog.codekills.net/archives/27-Fun-with-Firefox-Jitters.html for the details - basically, it happens when a <tr> has an onclick handler and an <a> inside that goes to the same URL...and even if this isn't what your app does, perhaps you can gain some insight from seeing how they went about debugging the problem.

TML
I am sorry I haven't provided any application code... but the code is just too big hehe.. that's why I was looking for a more generic answer like yours. Ok so, when I turned the JS off, it called the controller action once, but of course, didn't get to finish loading the whole page.. so then I checked through FireBug that AJAX is calling the controller action once more. Seems like I'm getting a little bit closer to the solution.. thanks! Gonna check that onclick thing you mentioned as well
IWannaLearn
Bleh.. I have debugged the JS with FireBug.. and everything looks fine.. That means that it's doing something like:1- call controller action2- go through all the javascript code3- call controller action againStill stucked :/
IWannaLearn
Capture the history with LiveHttpHeaders and post it so we can see the request chain?
TML
+2  A: 

Aggregating possible answers from other sources as per my comment:

  1. <img src="" /> and relatives.

    If you have places where you generate the src attribute of the img tag, make sure it isn't empty in any freak cases; a handful of browsers take the empty src as a prompt to load the page again. 1, 2, 3

    The same is true for an empty favicon, javascript or css href - generally anything where you're asking the browser to fetch an external resource, but no url is supplied, even in css1.

    The phenomenom is perhaps a more understandable if you consider, for example, where you're sending form data when you do <form action=""> (or even just <form>) - namely the same page.

  2. .htaccess shenanigans.

    Check your rewrite rule(s): Are you making the server take a roundtrip to your script for any static content (e.g. favicon1)? Do non-existent files trigger a call to your script, and is an external resource link pointing to one (e.g. an ancient css stylesheet that was finally deleted from the filesystem but someone forgot to remove it from the HTML source)?

  3. Browser-based debuggers.

    Some browser-based debuggers, e.g. firebug1, will send a second request to the page depending on circumstances, to gather data that wasn't natively supplied to them by the browser itself. Make sure you're not getting that.

See if any of those help you.

pinkgothic
Good tips all, pinkgothic.
TML