如何在Url.Action中发送多个参数? [英] How do you send multiple parameters in a Url.Action?
本文介绍了如何在Url.Action中发送多个参数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何在Url.Action
中发送多个参数?
How do you send multiple parameters in an Url.Action
?
我有一个带动作的控制器,我想要2个参数,但是没有收到第二个参数.
I have a controller with an action, and I want 2 parameters, but the 2nd parameter is not being received.
我的代码是:
@Url.Action("Products", "Jquery", new { categoryid = 1, Productid = 2})
Publc Action Jquery(int categoryid ,int Productid)
{
}
但是每次Productid
为null时,我只会收到categoryid
.
but I only receive categoryid
, every time Productid
is null.
请给我建议怎么办?
推荐答案
像这样尝试.
@Url.Action("Jquery", "Products", new { @categoryid = 1, @Productid = 2})
public ActionResult Jquery(int categoryid, int Productid)
{
return View();
}
您应该在操作中获得2个参数.假设Jquery
操作位于ProductController
you should get the 2 parameters in your action. Assuming the Jquery
Action is under ProductController
这篇关于如何在Url.Action中发送多个参数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文