I\'m getting an intermittent exception saying that asp.net mvc can’t find the action method. Here’s the exception:
A public action method \'Fill\' cou
We just had the same issue on our application and I was able to trace it to a javascript/jquery issue. We have links in our application defined using Html.ActionLink() that are later overridden into POSTs by jquery.
First we had defined the link:
Html.ActionLink("Click Me", "SomeAction", new { id = Model.Id})
Later we override the default action with our SomePostEventHandler function:
$(document).ready(function() {
$('#MyLink').click(SomePostEventHandler);
}
This was hitting our MVC action that had a HttpPost filter:
[HttpPost]
public ActionResult SomeAction(int id)
{
//Stuff
}
What we found is that most of the time this worked great. However, on some slow page loads (or really fast users), the user was clicking the link before the jquery $(document).ready() event was firing, meaning that they were trying to GET /Controller/SomeAction/XX instead of posting.
We don't want the user to GET that url, so removing the filter is not an option for us. Instead we just wired the onclick event of the action link directly (we had to change SomePostEventHandler() slightly for this to work):
string clickEvent = "return SomePostEventHandler(this);";
Html.ActionLink("Click Me", "SomeAction", new { id = Model.Id}, new { onclick = clickEvent })
So, moral of the story, for us at least, is that if you are seeing these errors, track down the URL that you THINK you are POSTing to and make sure you are.