How to deal with more than one value per key in ASP.NET MVC 3?

后端 未结 3 819
情话喂你
情话喂你 2020-12-29 09:21

I have the following problem: one of the system I\'m working in most important features is a search page. In this page I have some options, like records per page, starting d

3条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-29 09:31

    You should write either extension methods that target the routeValue collection or a custom model binder that transforms your Event parameter into a list always. If you view Event always being a list, just a commonly length 1 list will alleviate most of the problems you face.

    At this point you will just interact with a list interface. You could then write a custom binder to allow you to directly place that into the route correctly or you could unpack the list back into the query string. There's a software project based on this called Unbinder for unpacking objects into property/value pairs that you can easily use in query strings or other purposes.

提交回复
热议问题