ASP.NET MVC - 获取查询字符串值字符串值、ASP、NET、MVC

2023-09-02 10:28:24 作者:零点过十分

在ASP.NET MVC是你应该拿起查询字符串PARAMS您在ASP.NET的WebForms做同样的方式?还是在的[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

which will accept a query like .../someroute?someValue=abc&someOtherValue=123

除此之外,你可以看一下要求直接进行更多的控制。

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