1

If I run the following code I got error message "A public action method 'PostAction' was not found on controller...". Fiddler shows GET request instead of POST is used. I tried to replace Html.BeginForm by Ajax.BeginForm, it did not help. So what do I do wrong? Thanks.

@using (Html.BeginForm())
{ 
    @Ajax.ActionLink("ClickMe", "PostAction", new AjaxOptions { HttpMethod = "POST" }) 
}

[HttpPost]
 public virtual ActionResult PostAction() { ... }

UPDATE, additional info: That's how MVC generates Html anchor:

<a onclick="Sys.Mvc.AsyncHyperlink.handleClick(this, new Sys.UI.DomEvent(event), { insertionMode: Sys.Mvc.InsertionMode.replace, httpMethod: 'POST' });" href="/.../PostAction/">ClickMe</a>
SLaks
  • 868,454
  • 176
  • 1,908
  • 1,964
YMC
  • 4,925
  • 7
  • 53
  • 83
  • 1
    Right, but it's not just hyperlink, MVC handles its click event and tries to run it in POST mode, at least that's how it suppose to work. – YMC Sep 16 '11 at 01:09

1 Answers1

1

Oh, I just forgot to add references to MicrosoftAjax.js and MicrosoftMvcAjax.js. As I added them, everything works fine. Sorry for the silly post

YMC
  • 4,925
  • 7
  • 53
  • 83