Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post Feb 11, 2013 10:56 AM by bigbadmad
Jun 10, 2008 06:24 AM|LINK
My controller action is being invoked twice.
I even tried entering the action on the url in case something was going wrong with click the link --- the action is still being called twice.
I have custom filter attributes applied to my controller --- I commented them out so its not them.
Jun 10, 2008 07:05 AM|LINK
Can you post the code of the Controller and the view that is being rendered?
Jun 10, 2008 08:07 AM|LINK
Not to worry,
I have solved it --- kind of :)
Jun 10, 2008 04:42 PM|LINK
i've found this happen to me too a few times. i've found there's a tag in my page or ajax call referencing an empty URL, which browsers will interpret as the current page and request it again.
I haven't encountered it since preview 1 though, but my co-worker had this exact same problem that turned up because his ajax call had a URL of empty string.
Apr 21, 2009 07:19 AM|LINK
I have also encountered this, and after a while pulling my hair out i discovered the source of the issue in my situation.
I was experiencing a situation where everything seemed to be running fine, but when entering debug mode and stepping through things went wiggy. When any page was requested, the controller action would fire, do everything it was supposed to, pass everything
on to the view which would then render all the HTML to the browser window, and the page would become usable... however Visual Studio would still be busy.
After debugger had stepped through all of the View code, it was then jumping to the same specific action in a controller, no matter what page had originally been requested. Obviously, this action expecting certain params then threw an error. This wasn't
discovered for a while however as the HTML had already been served and displayed in the browser before the second action was called.
My page had an <img> tag referencing a .jpg file that no longer existed. Deleting the tag or supplying the source of an existing file solved the problem.
I'm not too knowledgable on browsers inner workings, but both IE and FF were producing the same result, so maybe upon realising that a resource wasn't downloaded the browsers retry with the same/similar request, hence the second call to the controller?
asp.net mvc controller action firing twice
Feb 11, 2013 10:56 AM|LINK
It's worth pointing out for anyone using Firefox and Firebug for testing that Firebug will cause every Action to be called twice. Grrr