Posting a large JSON object to ASP.NET MVC

how to pass json object to controller method in mvc 4
ajax post json data to mvc controller
pass json object to mvc controller
how to pass json data from view to controller in mvc
post json to mvc controller c#
how to bind json data to view in mvc
how to return large json data from mvc controller
how to send a model in jquery ajax post request to mvc controller method

I'm using KnockoutJS's mapping pluggin to convert my model into Knockout objects. But I'm having issues sending the large json object back to the server. My ajax call looks like this:

    url: "/home/DoStuff",
    type: "POST",
    data: JSON.stringify({ deal: ko.toJS(myObjectViewModel) }),
    contentType: "application/json",
    dataType: "json",
    success: function (result) {
    error: function (xhr, status, message) {

Executing this script never hits the DoStuff action in the controller. When I inspect with Firebug, the POST just keeps spinning. In the Net tab of Firebug, it says the Post Body is 159.9 KB and Total Sent is 165.1 KB (including the headers). If it was sent, why is it not hitting my breakpoint in the code?

But when I instead send just a property of myObjectViewModel, it posts fine and everything is successful. So that leads me to assume the issue is with the size of the data being posted. So I tried increasing the maxJsonLength.

            <jsonSerialization maxJsonLength="2147483644"></jsonSerialization>

This didn't help.

Is there something else I should be doing?

I guess my object exceeded the maximum number of members ASP.NET was allowed to deserialize. I added the below to increase it and it works.

    <add key="aspnet:MaxJsonDeserializerMembers" value="150000" />

UPDATE: So there was more to it because after I got it working, eventually it would stop working for what seems to be no reason. Firebug would again show the post just spinning without it hitting the code on the back end. Only after I closed Firefox, killed the IIS Express process and closed Visual Studio, did the post start working again. But closing VS seems to be key. After I got it working again, changing the code and re-running the app make the issue re-appear. When the issue occurs, not even a hard refresh will load the page. It'll just sit there spinning. The page will only reload after I kill the IIS Express process and rerun from VS.

So I dumped IIS Express and used full IIS on my machine instead. Looks like this solves the problem. Posting the large json data goes through every time without fail...even after changing code and recompiling.

IIS Express seems to handle posting small amounts of json fine but chokes on larger sets. I haven't tested thoroughly enough to 100% confirm this but I do know performance is more reliable with full IIS. Haven't tested VS's internal web server though.

Environment: Windows 8, Visual Studio 2012 Update 3

Handling larger JSON string values serialization in MVC, This happens due to fetching of large amount of data in JSON format via ajax call. So, here are the solution options to it: Solution 1: The common,� Step #2, Send Data To ASP.NET MVC. The data object has been serialized to JSON and sent to the server, so now we must prepare C# to handle the data object correctly.

I'm passing large JSON data which contains almost 1,50,00,000 characters to my controller, with below change in web.config:

    <add key="aspnet:MaxJsonDeserializerMembers" value="2147483644" />

This is working for me very nicely.....

Sending Complex JSON Objects To ASP.NET MVC View Using , In this article you will learn about View Model and sending complex JSON Objects to ASP.NET MVC View using JQuery Ajax. I was working on a MVC4 application that was serializing a large volume (1k+) of json objects to a controller. The system.web.extensions method didn't do anything, but the appSettings was the magic fix. Thanks! – TNCodeMonkey Oct 17 '12 at 20:59

You may need to bump the generic maximum request length (in kilobytes, example is 1GB)

    <httpRuntime maxRequestLength="1048576" />

And if you're using IIS 7, probably bump max content length (in bytes, example is 1GB)

      <requestLimits maxAllowedContentLength="1073741824" />

ASP.NET MVC, Since, complex or large input parameters are difficult to manage and share in ASP.NET MVC - How To Use AJAX With JSON Parameters Create target " JSON object Mapper" object class file according to the business Next Recommended Article Post Data To Controller Without Page Refresh In ASP. It's not about the size of the JSON being returned, since the Exception is thrown before the body of my method is even called. The problem is the default MVC model binder's JSON max length. The JSON that I am sending in the POST body is about 2mb. – aiokos Dec 15 '16 at 22:18 |

I had the same issue Posting large model object data (JSON) from client side to Server controller action. adding the below settings to config worked fine. thanks.

    <add key="aspnet:MaxJsonDeserializerMembers" value="150000" />

Sending JSON to an ASP.NET MVC Action Method Argument, This is where value providers, a new feature of ASP.NET MVC 2, enters to save the day. Whereas model binders are used to bind incoming data� Intro: Web application, ASP.NET MVC 3, a controller action that accepts an instance of POCO model class with (potentially) large field. Model class: public class View { [Required] [

Posting JSON Data to an MVC 3 Web Application, Posting JSON Data to an MVC 3 Web Application Below is a quick example on how easy it is to establish a data exchange mechanism between a JavaScript web app and an public long Id { get; set; } JSONstring is a "stringified" (or "serialized") JSON object that I serialized by using the JSON plugin offered at So: JSONstring = JSON.stringify(journalEntry); // journalEntry is my JSON object So the variable names in the $.post, and in the Controller method need to be the same name, or nothing will work. Good to know.

Posting large JSON to Controller fails silently � Issue #5551 � aspnet , When posting a large JSON file (several MB) to a Microsoft.AspNetCore.Mvc. Controller method, where the method is marked with [HttpPost] the Http IsEnvironment("Development")) { // This will push telemetry data through� Posting a large JSON object to ASP.NET MVC. Ask Question Asked 6 years, 11 months ago. Active 1 year, 4 months ago. Viewed 11k times 8. I'm using KnockoutJS's mapping

Deserializing Web Api parameter fails in case of large json � Issue , I have a Asp.Net Core 2.0 Web API service that has a HTTP Post Method that contains a byte[] parameter which fails to get deserialized when larger JSON like 30 mb is sent as body content thus having null value. aspnet / Mvc Archived You can post the data as StreamContent in HttpClient and read the� You can see the code, get JSON POST data from the Request object. Once you read StreadReader object and converted into the string. Then string will convert into TeamViewModel object help of JsonConvert.DeserializeObject method and finally get the TeamViewModel object.

  • I'm using IIS Express. Thanks, I tried both but it's still not getting to the server.