【问题标题】:URL.Action does not send data to method correctlyURL.Action 未正确向方法发送数据
【发布时间】:2013-08-03 01:17:33
【问题描述】:

我有这个对发送 w、h 和 id 的 MyMethod 的调用。但是,即使我更改名称,h 也始终为空。 w 和 id 有值。知道发生了什么吗?

showDialog('@Url.Action("MyMethod", "MyController",new { w = "300", h = "800", id = "testing" })', "800", "500", "弹出标题", null, callBack);

public ActionResult MyMethod(string w, string h, string id) {

}

【问题讨论】:

  • 把数字保留在字符串中是不好的。

标签: url.action


【解决方案1】:

虽然这不会给你带来麻烦,但数字应该保持在数字类型中,试试这个:

showDialog('@Url.Action("MyMethod", "MyController",new { w = 300, h = 800, id = "testing" })', "800", "500", "Popup Title", null, callBack);

public ActionResult MyMethod(int w, int h, string id) {

}

【讨论】:

  • 但是为什么一个参数取不到值呢?
  • 你检查过 POST 中的数据了吗?在萤火虫什么的?当您转到“NET”选项卡时,您可以在那里看到 xhr 请求,检查您发布到服务器的数据
猜你喜欢
  • 2013-04-26
  • 2019-11-04
  • 2018-05-14
  • 1970-01-01
  • 2012-02-11
  • 2017-08-10
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多