Ich versuche, das Ergebnis von meinem WCF-Dienst in json zu erhalten, wie Sie sehen können:Die Länge der Zeichenfolge überschreitet den Wert auf dem maxJsonLength property.C# gesetzt
public List<InquiryStatus> SearchInquiryStatus(string userid, string datestart, string dateend)
{
string result = "";
using (WebClient ClientRequest = new WebClient())
{
ClientRequest.Headers["Content-type"] = "application/json";
ClientRequest.Encoding = System.Text.Encoding.UTF8;
result = ClientRequest.DownloadString(ServiceHostName + "/MonitoringInquiryService.svc/SearchInquiryStatus/" +
userid + "/"
+ datestart + "/" + dateend
);
}
var javascriptserializer = new JavaScriptSerializer();
return javascriptserializer.Deserialize<List<InquiryStatus>>(result);
}
Aber ich bekomme diese Fehlermeldung:
Error during serialization or deserialization using the JSON JavaScriptSerializer. The length of the string exceeds the value set on the maxJsonLength property.
Parameter name: input
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.ArgumentException: Error during serialization or deserialization using the JSON JavaScriptSerializer. The length of the string exceeds the value set on the maxJsonLength property.
Parameter name: input
Als Hinweis, wenn ich meine Service-uRL http://reporting.demo.ir/MonitoringInquiryService.svc/SearchInquiryStatus/null/'20171106'/'20171113'
in Browser aufrufen bekomme ich das Ergebnis. gegoogelt ich meinen Fehler und ich fand dies:
<configuration>
<system.web.extensions>
<scripting>
<webServices>
<jsonSerialization maxJsonLength="50000000"/>
</webServices>
</scripting>
</system.web.extensions>
</configuration>
ich diese auf meinen UI Web-Config hinzugefügt .but i gleiche Fehler.
einmal versuchen, mit inlining 'MaxJsonLength' von Code-Einstellung' javascriptserializer.MaxJsonLength = Int32.MaxValue; ' –
@AkashKC es funktioniert. Danke. –
Ich vermute, Sie deserialisieren Ihre JSON in Controller, die nicht Wert von Webservices-Einstellung in web.config nehmen. Die jsonSerialization-Einstellung Web.config wird nur von Web-Services verwendet. –