ASP.Net MVC AJAX link not working

寵の児 提交于 2019-12-06 07:20:59

The problem was that the ajax action link makes a POST request by default and it was being directed to the other LogOn method (the one accepting POST) and that's why I wasn't hitting the breakpoint Also, it was failing because the necessary POST data was not being sent. Adding HttpMethod to the action link fixed it:

<%= Ajax.ActionLink("Log On", "LogOn", "Account", new AjaxOptions {
    UpdateTargetId = "lll",
    Confirm = "blah",
    HttpMethod = "Get"}) %>

It sounds like there is some javascript error on the page causing the javascript inserted to handle the AJAX request not to fire. Have you looked at it in FireBug on page load to see if all of your Javascript loading correctly? Also, do your versions of the Microsoft javascript libraries match the version of MVC that you are using? I remember at least once in the progression of versions that I had to manually update my versions of the Microsoft javascript libraries in my project. If your project has existed through multiple versions of MVC, I'd suggest tracking down the new libraries (create a new project and copy them to your old one or open the project archive in the install directory and extract them by hand) and installing them.

Did you include ajax client scripts in the head section:

  • MicrosoftMvcAjax.js
  • MicrosoftAjax.js
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!