【发布时间】:2018-09-20 06:40:41
【问题描述】:
我正在使用 ASP.NET MVC5 并通过 ajax 将对象列表传递给操作。 理想情况下,我想在列表中传递大约 10K 项,但由于某种原因,我不能传递超过 65 项。每次我尝试超过 65 时,我都会收到 500 内部服务器错误。我尝试使用断点进行调试,但似乎该调用甚至从未触发我的操作。动作代码是:
public ActionResult DownloadExcel(List<DbEntity> list)
{
FileDataViewModel fileData = new FileDataViewModel { FileName = "foo", FilePath = "bar" };
//I want to do something else here but that's not the point of this
return Json(new { fileData });
}
我的 Ajax 调用是:
$('#btn').click(function () {
dto = @Html.Raw(Json.Encode(Model));
console.log(dto);
//I have checked the console and the array is correct, there is no problem with the dto variable
$.ajax({
url: "/DbEntities/DownloadExcel",
contentType: "application/json; charset=utf-8",
method: "POST",
data: JSON.stringify(dto),
})
.done(function (response) {
document.getElementById("mySpan").innerHTML = "<hr>File created successfully<br>";
})
.fail(function (response) {
document.getElementById("error").innerHTML = "Error creating file";
});
});
【问题讨论】:
-
<system.web><httpRuntime executionTimeout="240" maxRequestLength="51200" /></system.web>你能把它设置成web.config再试一次吗? -
@AdrianBrand @Win 我已经设置了这些但仍然没有运气
<requestLimits maxAllowedContentLength="1073741824" /><httpRuntime targetFramework="4.5.2" maxRequestLength="1048576" executionTimeout="3600" />
标签: asp.net-mvc asp.net-web-api