感谢所有帮助过我的人,我正在用解决方案来表达我的话。我在代码中添加了以下内容并实现了目标。
$.ajax({
url: '@Url.Action("Insert_Candidates")',
data: { "selected_list": candidate_List},
type: "POST",
dataType: "json",
async: true,
success: function (response) {
alert(response.d);
},
failure: function (response) {
alert("fail");
}
});
控制器的方法在这里
[HttpPost]
[RequestFormLimits(ValueCountLimit = int.MaxValue)]
public async Task<IActionResult> Insert_Candidates([FromForm]List<RecuritementDTO> selected_list)
{
string result = "";
if (ModelState.IsValid)
{
try
{
result = count + " rows has been saved";
}
catch (Exception ex)
{
//throw;
string message = ex.ToString();
result = ex.Message.ToString();
}
}
return Json(new { d = result });
}
Startus.cs在这里
services.Configure<FormOptions>(options =>
{
options.ValueCountLimit = 10; //default 1024
options.ValueLengthLimit = int.MaxValue; //not recommended value
options.MultipartBodyLengthLimit = long.MaxValue; //not recommended value
options.MemoryBufferThreshold = Int32.MaxValue;
});
services.AddMvc(options =>
{
options.MaxModelBindingCollectionSize = int.MaxValue;
});
这是 Webconfig 代码(我也添加了这个......可能它帮助我过桥)
<system.web>
<httpRuntime maxRequestLength="1048576" />
</system.web>
<system.webServer>
<security>
<requestFiltering>
<requestLimits maxAllowedContentLength="2147483648" />
</requestFiltering>
</security>
</system.webServer>
<system.web.extensions>
<scripting>
<webServices>
<jsonSerialization maxJsonLength="50000000"/>
</webServices>
</scripting>
</system.web.extensions>
这就是我对代码所做的所有更改,并且已经完成。我希望这段代码可以帮助我们的堆栈团队成员。
干杯:)