Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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 ?

like image 206
user49126 Avatar asked Jan 15 '13 13:01

user49126


1 Answers

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

like image 52
Youssef Moussaoui Avatar answered Oct 21 '22 13:10

Youssef Moussaoui