1.You can create custom MediaTypeFormatter by inheriting abstract BufferedMediaTypeFormatter.
2.To add it to your web api,make changes in HttpConfiuration in Startup.cs
<pre class="prettyprint prettyprinted"><span class="pln"> config</span><span class="pun">.</span><span class="typ">Formatters</span><span class="pun">.</span><span class="typ">Add</span><span class="pun">(</span><span class="kwd">new</span> CustomFormat <span class="pun">());</span> </pre>
3. BufferedMediaTypeWritters has two methods WriteToStream(write in custom format(Serialize)) and ReadFromStream(read the custom format(deserialize)).
public class CustomFormat :BufferedMediaTypeFormatter { public CustomFormat() { SupportedMediaTypes.Add(new MediaTypeHeaderValue("text/csv")); } public override bool CanReadType(Type type) { throw new NotImplementedException(); } public override bool CanWriteType(Type type) { throw new NotImplementedException(); } }