user49126
user49126

Reputation: 1863

ASP.NET WebApi Custom Serialization

I have an action method which returns a DataRow object. Unfortunately the webapi serializer doesn't serialize the object properly. Is there any place where I can place a custom serialization code just for this particular type ?

Upvotes: 7

Views: 7950

Answers (1)

Youssef Moussaoui
Youssef Moussaoui

Reputation: 12395

You'll probably want to create a custom MediaTypeFormatter that returns true for DataRow-typed objects in its CanWrite method.

Here's a good starting point for how to write and register your own formatter:

http://www.asp.net/web-api/overview/formats-and-model-binding/media-formatters

Upvotes: 7

Related Questions