As a part of the API for our product, we have the need to allow the UI to send us a parcel of data, and we need to process it differently based solely on a single parameter in the data. We have decided to create an abstract model class to handle this, but MVC’s DefaultModelBinder
doesn’t work out of the box on abstract classes (or interfaces). There are many discussions out there on this, and the accepted way to solve this problem is to create a new ModelBinder
class that has more knowledge of the internals of your application than the default does. I thought about this some, and I decided to try out a few tweaks to the process.
October 2013
Accepting multiple parameters the “RESTful” way using ASP .NET Web API
I came upon a requirement at work to support accepting multiple ids in the Url of a “REST” request. I have no idea if this is actually considered RESTful or not, but the task was to formulate the URL like so:
GET /FooResource/id1;id2;id3;id4/
The intention was to be able to retrieve multiple instances of FooResource
with one request.
So, I came up with the following MVC ActionFilter to make my life a little bit easier:
Continue reading…