We had the same problem in our application, and I was able to trace it back to the javascript / jquery problem. We have links in our application defined using Html.ActionLink (), which are later redefined in POSTs by jquery.
First, we defined the link:
Html.ActionLink("Click Me", "SomeAction", new { id = Model.Id})
Later we will override the default action using our SomePostEventHandler function:
$(document).ready(function() { $('#MyLink').click(SomePostEventHandler); }
This influenced our MVC action with the HttpPost filter:
[HttpPost] public ActionResult SomeAction(int id) {
We found that most of the time this worked fine. However, on some slow page loads (or really fast users), the user clicked the link before the jquery $ (document) .ready () event was fired, which means they tried GET / Controller / SomeAction / XX instead of posting.
We do not want the user to receive this URL, so removing the filter is not an option for us. Instead, we simply linked the onclick event of the action link directly (we had to modify SomePostEventHandler () a bit to make this work):
string clickEvent = "return SomePostEventHandler(this);"; Html.ActionLink("Click Me", "SomeAction", new { id = Model.Id}, new { onclick = clickEvent })
So, the moral of this story, at least for us, is that if you see these errors, keep track of the URL where you THINK YOU ARE LOST, and make sure you are.
jslatts Oct 29 2018-10-29 14:23
source share