发布大串的Web API控制器 [英] Post large string to Web API controller

查看:102
本文介绍了发布大串的Web API控制器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下控制器

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

   }
}

我从后浏览器 jQuery.post 一些数据。国家的长度应为29915个字符,但 currentState的变量只有21621个字符。字符串的末尾将丢失。
我检查,如果浏览器发送的所有数据到服务器,它的作用。所以某处服务器上的问题。

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.

推荐答案

设置 ReadBufferSize 帮助:

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

这篇关于发布大串的Web API控制器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆