The ASP.NET MVC DocumentViewer uses an ASP.NET controller to manage incoming client requests using JSON. The default JSON size of 4MB can be too small for handling larger files. This article shows how to replace the default JavaScriptSerializer with Json.NET.

In your ASP.NET Web Application, install the popular and de-facto standard Newtonsoft.Json:

Install-Package Newtonsoft.Json

Then create a class JsonDotNetValueProviderFactory derived from ValueProviderFactory:


In the Global.asax.cs file of your ASP.NET application, add the following code:


This code removes existing JsonValueProviderFactory objects and activates the newly created factory.

The complete Global.asax.cs of a new project should look like this:


After this change, the ASP.NET controllers use Json.NET to deserialize incoming payloads and can handle unlimited file sizes loaded into the DocumentViewer.