Wednesday, February 22, 2012

Found the solution

I asked my question on the asp.net forum and I got the answer. Go here to see the solution.

Anyway, I will include the answer here just in case the post disappeared in the future.

public class ReadAsSingleObjectPolicy : IRequestContentReadPolicy
{
  public RequestContentReadKind GetRequestContentReadKind(HttpActionDescriptor actionDescriptor)
  {
    return RequestContentReadKind.AsSingleObject;
  }
}
GlobalConfiguration.Configuration.ServiceResolver
  .SetService(typeof(IRequestContentReadPolicy), new ReadAsSingleObjectPolicy());

3 comments:

MA said...

Hey, you told that you found the solution, I also tried to implement same things but its giving me internal server error on response.

Could you please describe me how you have solved the issue. I am already trying for this for more than 4 hours now.

Conrad said...

The solution I propose doesn't work for you? Or you don't know how to integrate into your solution?

MA said...

Maybe I couldn't integrate, the base line is that I want things to be solved, if you can guide me though will be great help. I have created the class as you said, and added the entry on global.asax, I am doing anything wrong....