ASP.NET MVC - 获取 QueryString 值 [英] ASP.NET MVC - Getting QueryString values

查看:63
本文介绍了ASP.NET MVC - 获取 QueryString 值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 ASP.NET MVC 下,您是否应该像在 ASP.NET WebForms 中一样获取 QueryString 参数?或者 [AcceptVerbs(HttpVerbs.Get)] 声明是否以某种方式被使用?

Under ASP.NET MVC are you supposed to pick up QueryString params the same way you do in ASP.NET WebForms? or does the [AcceptVerbs(HttpVerbs.Get)] declaration get used somehow?

推荐答案

可以简单地通过在动作上使用参数来接受查询字符串参数 - 即

Query string parameters can be accepted simply by using an argument on the action - i.e.

public ActionResult Foo(string someValue, int someOtherValue) {...}

它将接受像 .../someroute?someValue=abc&someOtherValue=123

除此之外,您可以直接查看请求以获得更多控制权.

Other than that, you can look at the request directly for more control.

这篇关于ASP.NET MVC - 获取 QueryString 值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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