In ASP.NET MVC, how do I get a parameter dictionary in action?

Most of the actions in my controller have statically defined parameter lists, so they fit well with the standard tutorial examples:

public ActionResult SomeAction(string id, string arg1, string arg2)
{
    // use arg1, arg2...
}

      

But I have one nasty case where the view merges the form dynamically, so the set of parameters is completely dynamic. I would be happy with mapping string names to string values.

I've tried this:

public ActionResult TroublesomeAction(string id, IDictionary<string, string> args)
{
    // loop through args...
}

      

But args

a null

. What's the easiest way to actually get the famous "parameter dictionary" that we hear so often about in error messages?

And if there is no easy way, how would I do it the hard way?

0


a source to share


1 answer


From the controller, we have access to this:

Request.Form

      



Which contains exactly what I need, so there is no need to match the action argument.

0


a source







All Articles