How to replace default JSON serialization in ASP.NET

May 8, 2012 at 7:39 PM

I'm writing a web service using ASP.NET 4.0 that is using WebMethods to process and return requests as JSON.  I'd like to replace the default Microsoft JSON serialization/deserialization with JSON.NET. 

This should be a really easy answer to find since its probably a very common use case for the library.  Even if this is not possible, I'd expect to find something saying that.  I've spent at least 3 hours trying to find this answer.  I've looked through the documentation and discussions on this web site.  I searched 2+ hours using Google then Bing (gave up on Google) and finally Alta Vista (gave up on Bing), etc.  Google kept returning results with "JSON" and "NET" but not "JSON.NET" (even when I used quotes).  Anyway, I can't find the answer to this very simple question anywhere! 

What I can find are lots of information about using JSON.NET with MVC or WebAPI.  That's really nice if you're using those, but I'm not.  Maybe the solution is the same or similar, but my experience with ASP.NET is somewhat limited so I don't know all the ins-and-outs of all Microsoft's web technologies.

Could someone please provide an answer to this.  Then may I suggest a very conspicuous page be added to the documentation tree on here titled something like "Integration with ASP.NET".  A page listing all of Microsoft's technologies (ASP.NET 1/2/3/4, MVC 1/2/3/4, WebAPI, WCF, etc) and either instructions or links on how to enable JSON.NET for each of them would be super useful to many new users I'm sure.  And if there are technologies that don't support JSON.NET (for instance ASP.NET v1) just state that clearly under the "ASP.NET 1.0" heading. 

Please, save others from the headache I've been experiencing.

Thanks in advance.

Coordinator
May 8, 2012 at 9:55 PM

You can't.

May 9, 2012 at 4:12 AM

Thanks.  That would explain why I couldn't find anything with all that searching.  Hopefully this question will save others from searching.