webapi batch requests

亡梦爱人 提交于 2019-12-24 16:12:43

问题


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 http://bradwilson.typepad.com/blog/2012/06/batching-handler-for-web-api.html#more 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:

  • .net 4.0
  • VS 2010
  • mvc 4 front end (calls webapi)
  • webapi as a service tier

Has anyone else had any success with batched messages and webapi?


回答1:


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 MVC4 RTM here or simply off Nuget.



来源:https://stackoverflow.com/questions/11998556/webapi-batch-requests

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!