asp.net-mvc - 如何在 Url.Action 中发送多个参数?

标签 asp.net-mvc asp.net-mvc-3 c#-5.0

如何在 Url.Action 中发送多个参数? ?

我有一个带有 Action 的 Controller ,我想要 2 个参数,但没有收到第二个参数。

我的代码是:

@Url.Action("Products", "Jquery", new { categoryid = 1, Productid = 2})

Publc Action Jquery(int categoryid ,int Productid)
{

}

但我只收到categoryid , 每次Productid一片空白。

请建议我该怎么做?

最佳答案

我有同样的问题,添加了@'s并且没有工作。

对我有用的是@Html.Raw操作说明。

@Html.Raw(@Url.Action("Jquery", "Products", new { categoryid = 1, Productid = 2}))

public ActionResult Jquery(int categoryid, int Productid)
{
    return View();
}

这样就可以得到 Controller 中的所有参数,而不仅仅是第一个。

关于asp.net-mvc - 如何在 Url.Action 中发送多个参数?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24178320/

相关文章:

c# - HTTP 错误 414。请求 URL 太长。网站

c# - umbraco 中的 URL 重定向,当找不到文档时,重定向到其他地方

jquery - 客户端验证不适用于重用和嵌套的复杂属性

html - 链接在 Firefox 中不起作用

asp.net-mvc-3 - 在 ASP.net MVC View 页面上使用 UniDynArray

C#5 ReadAsync 和迭代器

c# - 在具有 3 层架构的 ASP.NET MVC 应用程序中验证业务规则的更好方法是什么?

c# - 发现多个类型与名为 'Home' 的 Controller 匹配 - 在两个不同的区域

multithreading - 我什么时候应该使用 async/await,什么时候不应该使用?

winforms - 在运行时调用多线程 DLL