ASP.Net MVC AJAX链接无法使用 [英] ASP.Net MVC AJAX link not working

查看:275
本文介绍了ASP.Net MVC AJAX链接无法使用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有这个环节,努力实现AJAX登录,我的网页上:

I have this link, in an effort to implement AJAX log on, on my page:

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

有与附近ID LLL一个div。当我点击链接,我得到的嗒嗒确认(只增加了调试的目的,该行为没有它这是相同的),但是没有任何反应。无请求没有到达服务器(因为我在登录操作方法断点)。这是Chrome和IE8。在FF3它打开登录视图,但作为一个页面,它不通过的AJAX下载它。

There's a div with id lll nearby. When I click the link, I get the blah confirmation (just added for debugging purposes, the behavior without it it's the same) but then nothing happens. No request ever reaches the server (because I have a breakpoint on the LogOn action method). That is in Chrome and IE8. In FF3 it opens the logon view but as a page, it doesn't download it through AJAX.

任何想法可能是错误的?

Any ideas what might be wrong?

推荐答案

问题是,AJAX操作链接,使一个默认的POST请求,它被引导到其他登录方法(一接受POST),这就是为什么我不打了断点此外,有人失败,因为必要的POST数据没有被发送。添加HttpMethod的动作链接固定它:

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"}) %>

这篇关于ASP.Net MVC AJAX链接无法使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆