1

in MVC3, is route data always in the modelState collection, or is it only in the modelState collection if that key is specifically requested as per the model binder for the applicable controller action ?

To illustrate:

public HomeController { ActionResult Index(string id)

Home/Index/5?something=else

Would the modelState dictionary have the key something and value else, or would it only have the key id?

Chris Marisic
  • 32,487
  • 24
  • 164
  • 258
  • 1
    To expand on olivehour's answer since `something` was never bound in any way to any `model` it won't be in the ModelState. Only when items are bound in such a way are they added. – Buildstarted Dec 09 '11 at 16:09

1 Answers1

2

It is only in the ModelState when it is part of the action method argument(s). To get other route info, you need to look at the controller's RouteData property.

danludwig
  • 46,965
  • 25
  • 159
  • 237