Skip to content

Instantly share code, notes, and snippets.

View stamminator's full-sized avatar

Jacob Stamm stamminator

  • Intech Investments
  • South Florida
View GitHub Profile
stamminator /
Last active February 4, 2022 17:14
Using System.Text.Json serialization in ASP.NET MVC 5

This gist shows the various pieces needed to implement System.Text.Json instead of System.Web.Script.Serialization.JavaScriptSerializer or Newsonsoft.Json in ASP.NET MVC 5. We need to make the replacement in two places: the model binding for deserializing requests, and JsonResult for serializing responses.

For the model binding, implement a custom Value Provider to replace the default JsonValueProviderFactory.


using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;