Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ASP.NET MVC - Getting QueryString values

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?

like image 429
BuddyJoe Avatar asked Mar 09 '09 20:03

BuddyJoe


People also ask

What is QueryString in MVC?

Generally, the query string is one of client-side state management techniques in ASP.NET in which query string stores values in URL that are visible to Users. We mostly use query strings to pass data from one page to another page in asp.net mvc. In asp.net mvc routing has support for query strings in RouteConfig.


1 Answers

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

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

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

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

like image 134
Marc Gravell Avatar answered Oct 07 '22 01:10

Marc Gravell