I have an MVC project and I'm trying to send a JSON object that has a large string in it to my controller. My ajax call fails instantly, not even getting to the controller, and gives me a 500 error. I've made modifications to my web.config to increase JSON serialization and content length. This does work when the string is smaller, but when it gets large it errors instantly. Below is my code:
Web Config Settings:
<scripting>
<webServices>
<jsonSerialization maxJsonLength="2147483644"/>
</webServices>
</scripting>
<httpRuntime targetFramework="4.5" maxRequestLength="1048576"/>
<add key="aspnet:MaxJsonDeserializerMembers" value="2147483647"/>
-Client side code
var Response = {
TemplateResponse: 'SUPER DUPER LONG STRING',
ID: '1'
};
$.ajax({
url: SaveResponseUrl,
cache: false,
type: 'POST',
contentType: 'application/json; charset=utf-8',
data: ko.toJSON(Response),
error: function (err) {
showErrorDialog(err.responseJSON.message);
}});
-Controller code
public JsonResult SaveResponse(ResponseModel response)
{
vm.SaveResponse(response);
return Json("", JsonRequestBehavior.AllowGet);
}
How can I send this large JSON to my controller?