在Html.Action指定查询字符串 [英] Specify QueryString in Html.Action

查看:145
本文介绍了在Html.Action指定查询字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

0I希望的动作的输出插入的图。问题是,该操作需要在查询字符串一些信息。有没有一种方法,包括在行动查询字符串PARAMS?

例如:

  @ Html.Action(GET,联系人)

要获得正确的结果返回,我需要通过?页次= 1的动作。

  @ Html.Action(获取?页次= 1,联系人),遗憾的是不工作


解决方案

  @ Html.Action(YourActionName,YourControllerName,新的{页次= 1})

使用的超负荷动作()来定义路由值。

MSDN参考

时的动作方法真名叫的get()?如果是这样,你的控制器名称为联系人,修改后的code将需要:

  @ Html.Action(GET,联系人,新的{页次= 1})

0I want to insert the output of an action into a view. The problem is that the action requires some info in the querystring. Is there a way to include the querystring params in Action?

Example:

@Html.Action("Get","Contacts")

To get the proper result back, I need to pass ?pagenum=1 to the action.

@Html.Action("Get?pagenum=1","Contacts")  unfortunately doesn't work

解决方案

@Html.Action("YourActionName", "YourControllerName", new { pagenum = 1 })

Use the overload of Action() to define route values.

MSDN Reference

Is your Action Method really named Get()? If so, and your controller name is Contacts, your modified code would need to be:

@Html.Action("Get", "Contacts", new { pagenum = 1 })

这篇关于在Html.Action指定查询字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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