Json字符串长度超过了asp.net web表单上的最大值



我正在尝试在web表单页面中显示telerik下拉列表,代码如下

private void LoadCustomerControl()
   {
       try
       {
           IControlPanelPersistenceProvider persistenceProvider = new ControlPanelDatabaseProvider();
           List<CustomerDataGrid> customerCollection = persistenceProvider.ListCustomerGrid(false);
           if (customerCollection != null && customerCollection.Count != 0)
           {
               cboCustomer.DataSource = null;
               cboCustomer.DataSource = customerCollection;
               cboCustomer.DataBind();
           }
           else
           {
               //TODO add here message
               m_btnSubbmit.Visible = false;
               m_btnModifyCustomer.Visible = false;
           }
       }
       catch (Exception ex)
       {
           string excep = ex.ToString();
           //TODO add log here
       }
   }

问题是我得到的列表很大,然后它在浏览器中引发了这个错误

异常消息:使用进行序列化或反序列化时出错JSON JavaScriptSerializer。字符串的长度超过在maxJsonLength属性上设置的值。

我已经尝试添加到网络配置

<configuration>
  <system.web.extensions>
    <scripting>
      <webServices>
        <jsonSerialization maxJsonLength="2147483644 "/>
      </webServices>
    </scripting>
  </system.web.extensions>
</configuration>

我还尝试新建一个javascriptserializer,并将其maxjsonlength设置为Int32.MaxLength,序列化数据源,然后反序列化回CustomerDataGrid列表,但都不起作用。

对LoadCustomerControl的调用是通过完成的

if (Request.QueryString.Get("customerId") != null && Request.QueryString.Get("customerId").Length > 0)
           {
               //Is comming from CustomerPage, display the customer
               LoadCustomerControl();
               cboCustomer.SelectedValue = Request.QueryString.Get("customerId");
               cboCustomer.Text = GetCustomerName(int.Parse(Request.QueryString.Get("customerId").ToString()));
               m_btnModifyCustomer.Visible = true;
           }
}

谢谢,

尝试将以下内容添加到应用程序设置中<add key="aspnet:MaxJsonDeserializerMembers"value="2147483644"/>

最新更新