通用处理程序参数大小限制?

我有一些JavaScript代码生成一个非常长的脚本,然后将其发送回服务器,以创建一个csv的通用处理程序。

我发送数据的JavaScript代码是:

function postwith(to, p) { var myForm = document.createElement("form"); myForm.method = "post"; myForm.action = to; for (var k in p) { var myInput = document.createElement("input"); myInput.setAttribute("name", k); myInput.setAttribute("value", p[k]); console.log(k+":"+p[k]); myForm.appendChild(myInput); } document.body.appendChild(myForm); myForm.submit(); document.body.removeChild(myForm); 

}

在我的控制台中,我可以看到整个字符串被添加到表单中(“console.log(k +’:’+ p [k]);”所以客户端似乎工作正常。

在我检查请求/响应的网络视图中,我可以看到“内容”(表单数据属性的名称)不完整 – 它在中间被剪切。

服务器端非常简单 – 将内容作为csv发回:

 public class Excel : IHttpHandler { public void ProcessRequest (HttpContext context) { context.Response.ContentType = "text/csv"; context.Response.AddHeader("Content-Disposition", "attachment; filename=" + context.Request["Report"] +System.DateTime.Now.Ticks+ ".csv"); string content = context.Request["Content"]; content = content.Replace(";", System.Environment.NewLine); System.Text.UTF8Encoding uc = new System.Text.UTF8Encoding(true); context.Response.Output.WriteLine(content); context.Response.End(); } public bool IsReusable { get { return false; } } 

}

我的猜测是服务器需要以某种方式配置以允许更大的post…

您可以在web.config中设置允许的最大内容长度。 默认值为30,000,000字节:

       ...