2012-04-20 51 views
1

我有以下控制器邮政大串的Web API控制器

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

    } 
} 

我从浏览器发布的一些数据与jQuery.post。状态的长度应为29915个字符,但currentState变量只有21621个字符。字符串的末尾丢失。 我检查了浏览器是否将所有数据发送到服务器,并且确实如此。所以在服务器上的某处出现问题。

+0

你怎么设置的内容类型? – Aliostad 2012-04-20 12:18:15

+0

Firebug显示请求'Content-Type'头是'application/x-www-form-urlencoded;字符集= UTF-8'。 – 2012-04-20 12:24:09

+0

我刚刚用30K测试过,工作正常。你的字符串是否包含非编码的东西? – Aliostad 2012-04-20 12:30:37

回答

0

设置ReadBufferSize帮助:

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