I am looking for a way to batch requests to the server. I found a post by Brad Wilson outlining how to make a batch handler using a message hanlder <a href="http://bradwilson.typepad.com/blog/2012/06/batching-handler-for-web-api.html#more" rel="nofollow">http://bradwilson.typepad.com/blog/2012/06/batching-handler-for-web-api.html#more</a> but I wasn't able to get this working.
first I had compile errors because webapi did not understand "route-specific endpoint handler" like Brad's example used. there were also problems with the media type and/or formatter (can't remember which). My next attempt was to make a batch controller. so instead of a batch handler I had a batch controller. I almost has this working except when I used the MessageHandlerInvoker to call the individual commands I got exceptions about the additional handlers I have regsstered (1 for logging request/response and another to mimic user authentication).
At that point I stopped and reverted back to individual requests, not ideal, but it works.
My environment:<ul><li>.net 4.0</li> <li>VS 2010</li> <li>mvc 4 front end (calls webapi)</li> <li>webapi as a service tier</li> </ul>
Has anyone else had any success with batched messages and webapi?Answer1:
To be able to use per-route handlers you need ASP.NET Web API RTM which was only released yesterday (at the time when Brad wrote the article, it would only work with nightly MyGet feed builds or against Codeplex source).
You can get entire <a href="http://www.asp.net/mvc/mvc4" rel="nofollow">MVC4 RTM here</a> or simply off Nuget.