Post large string to Web API controller

梦想的初衷 提交于 2020-01-16 00:56:26

问题


I have a following controller

public class MyController : ApiController
{
   [HttpPost]
   public string LoadData(string currentState)
   {

   }
}

I post some data from browser with jQuery.post. The length of the state should be 29915 characters, but currentState variable has only 21621 characters. The end of the string is lost. I checked if browser sends all data to the server and it does. So the problem somewhere on the server.


回答1:


Setting the ReadBufferSize helps:

protected void Application_Start(object sender, EventArgs e)
{
   GlobalConfiguration.Configuration.Formatters.FormUrlEncodedFormatter.ReadBufferSize = 256 * 1024; // 256 KB
}


来源:https://stackoverflow.com/questions/10245061/post-large-string-to-web-api-controller

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!