我得到这个错误:
该JSON请求是太大而不能反序列化。
下面是这种情况出现的场景。 我有一类国家,其持有的该国的航运端口的列表
public class Country
{
public int Id { get; set; }
public string Name { get; set; }
public List<Port> Ports { get; set; }
}
我使用在客户端KnockoutJS使级联下拉菜单。 因此,我们有两个下拉菜单,其中第一个是国家的一个数组,而第二个是国家的港口。
一切工作正常,到目前为止,这是我的客户端脚本:
var k1 = k1 || {};
$(document).ready(function () {
k1.MarketInfoItem = function (removeable) {
var self = this;
self.CountryOfLoadingId = ko.observable();
self.PortOfLoadingId = ko.observable();
self.CountryOfDestinationId = ko.observable();
self.PortOfDestinationId = ko.observable();
};
k1.viewModel = function () {
var marketInfoItems = ko.observableArray([]),
countries = ko.observableArray([]),
saveMarketInfo = function () {
var jsonData = ko.toJSON(marketInfoItems);
$.ajax({
url: 'SaveMarketInfos',
type: "POST",
data: jsonData,
datatype: "json",
contentType: "application/json charset=utf-8",
success: function (data) {
if (data) {
window.location.href = "Fin";
} else {
alert("Can not save your market information now!");
}
},
error: function (data) { alert("Can not save your contacts now!"); }
});
},
loadData = function () {
$.getJSON('../api/ListService/GetCountriesWithPorts', function (data) {
countries(data);
});
};
return {
MarketInfoItems: marketInfoItems,
Countries: countries,
LoadData: loadData,
SaveMarketInfo: saveMarketInfo,
};
} ();
在中国这样的国家被选中,其中有大量的端口出现问题。 所以,如果你有你的阵列中的3或4次“中国”,我想将它发送到服务器保存。 出现此错误。
我应该怎么做才能解决这个问题?