Reputation:
I would like to get the parameters from a URL into a Dictionary for the Controller. Here is an example:
URL:http://localhost/Application/View/Action?a=1&b=2
Controller Code
public ActionResult Action(Dictionary<string,string> args)
{
//args["a"] = "1"
//args["b"] = "2"
return view(args); //sends entire dictionary
}
I have tried using extending the IValueProvider class but to no avail.
Upvotes: 1
Views: 1342
Reputation: 2123
You can use the provided
Request.QueryString
to get those parameters. Its a NameValueCollection already (You can also access the keys there or iterate it as any other IEnumerable out there).
Upvotes: 2