MVC QueryString into Dynamic Object

Viewed 4116

Is there a way to populate a Dynamic object with Query String parameters?

This is so that my search parameters in the QS can vary without binding them directly to a container object or having to change the signature of the search method.

e.g.

Inbound URL: www.test.com/Home/Search?name=john&product=car&type=open&type=all

public ActionResult Search()
{
    dynamic searchParams = // **something magic here**

    var model = getResults(searchParams);
    return View(model);
}

The populated searchParams object should look like:

{
    name = "john",
    product = "car",
    type = { "open", "all" }
}

Any ideas?

3 Answers
Related