MVC的查询字符串参数强类型actionlinks [英] QueryString Parameters in Mvc strongly typed actionlinks

查看:221
本文介绍了MVC的查询字符串参数强类型actionlinks的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我觉得没有可用的同时,通过强类型的操作链接创建ActionLink的增加比动作参数列表中的其他参数超载。我想要的是添加额外的参数,将在查询字符串可用。

例如用行动 MyAction(INT ID)控制器中的 myController的
Html.ActionLink(MC => mc.MyAction(5),我的行动)会产生链接类似的 myController的/ MyAction / 5 ,但我想要的是追加查询字符串喜欢这个。
myController的/ MyAction / 5?QS =值即可。有什么办法,使用强类型actionlinks,实现这一目标。


解决方案

 <%= Html.ActionLink(LINKNAME,动作,控制器,新的{参数1 =值1,参数2 =值2} ,新{})%GT;

I think there is no overload available to add parameters other than the action parameters list while creating actionlink through strongly typed action links. What I want is to add extra parameters which will be available in querystring .
For example with action MyAction(int id) in controller MyController. Html.ActionLink(mc=>mc.MyAction(5),"My Action") will produce link something like MyController/MyAction/5 but what I want is append querystring like this. MyController/MyAction/5?QS=Value. Is there any way,using strongly typed actionlinks, to achieve this.

解决方案

<%=Html.ActionLink(LinkName, Action, Controller, new { param1 = value1, param2 = value2 }, new { })%>

这篇关于MVC的查询字符串参数强类型actionlinks的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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