简体   繁体   中英

asp.net mvc 3: reverse of modelbinder while serializing to url

In our application we have an object which is called a search descriptor. We have a custom modelbinder for it to make it all work. It reads certain know properties like q oorsort and page from the URL (or post data).

Now somewhere else in the application, we need a URL to the searchpage. We use the searchdescriptor class to model what we want to search for.

I needed a way to convert all the things in searchdescriptor to a routevaluedictionary and then merge that with the action name and controller name.

No a big deal, I just added it to the class. However, modelbinders let me extend mvc before my controller kicks in, I want something similar for serialization to URL.

We also use T4mvc, but passing a complex object to an action method just serializes it to the tostring.

Does this mechanism already exist? Or do we have to code this ourselves?

As of now the mechanism does not exist. We ended up only needing this for a couple of models, which we could do with just custom toQueryString code and t4mvc's 0-parameter action methods.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM