weixin_33696106 2010-06-17 20:48 采纳率: 0%
浏览 35

Ajax.ActionLink不发布

I am trying to navigate to an MVC action by POSTing rather than GETting. (The action is a DELETE, and I don't want it reachable by an external link.)

I am using a link in a grid generated by

 Ajax.ActionLink("Remove", "Delete", new { saID = Model.Said, id = e.id }, new AjaxOptions { HttpMethod = "POST", Confirm = "Are you sure you want to delete this item?" })

Which generates the following HTML:

<a href="/Equipment/Delete/102424/229933" onclick="Sys.Mvc.AsyncHyperlink.handleClick(this, new Sys.UI.DomEvent(event), { insertionMode: Sys.Mvc.InsertionMode.replace, confirm: 'Are you sure you want to delete this item?', httpMethod: 'POST' });">Remove</a>

My problem is that when I click on the link, I am reaching the Delete action via a GET rather than a POST, AND the Confirm dialog is not taking place. I have been googling this for several hours and just keep getting wrapped around the axle. What am I doing wrong?

  • 写回答

2条回答 默认 最新

  • weixin_33694172 2010-06-17 21:02
    关注

    It's likely that you have some other javascript error on your page that is preventing the javascript that handles the AJAX POST from running. In this case, the link falls back to it's default behavior (GET). The easiest thing to do is use the IE8 developer tools or Firefox/Firebug (I prefer these) and look to see if you have any errors in the console when the page loads or your action is invoked. If you are using IE you'll need to use Internet Options -> Advanced and uncheck Disable script debugging.

    Fix your javascript error and I think it will simply start working.

    评论

报告相同问题?

悬赏问题

  • ¥15 HFSS 中的 H 场图与 MATLAB 中绘制的 B1 场 部分对应不上
  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?