Reputation: 5489
I have a web service returning some Json stuff to my iPhone application and it works fine as long as the amount of returned data is kind of small but if I increase the amount of data that is returned the application is not able to process it. Is there a way to solve this, can't possibly be a limit of 218KB...?
This is my current code:
[WebService(Namespace = "http://mydomain.com/webservicesfeed")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[System.ComponentModel.ToolboxItem(false)]
// To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line.
[System.Web.Script.Services.ScriptService]
public class feedPerson : System.Web.Services.WebService
{
[WebMethod(BufferResponse = false)]
[ScriptMethod(ResponseFormat = ResponseFormat.Json)]
public List<Person> getData()
{
List<Person> res = new List<Person>();
res = searchPerson("32.8762", "13.1875");
return res;
}
}
If I call the web service throw jQuery it also fails so I guess the problem is at the web service..
This is the jQuery code I used to try it out:
<script type="text/javascript">
$.ajax({
type: "POST",
contentType: "application/json; charset=utf-8;",
url: "http://mydomain.com/feedPerson.asmx/getData",
dataType: "json",
success: function (data, textStatus, jqXHR) {
alert(data.d[0]);
},
error: function (jqXHR, textStatus, errorThrown) {
alert("Fail");
}
});
</script>
How could this be solved?
Upvotes: 1
Views: 1831
Reputation: 5489
Catching the error gave me the following information: "The length of the string exceeds the value set on the maxJsonLength property".
Then I found this post: Can I set an unlimited length for maxJsonLength in web.config?
and by setting the following in my web.config:
<system.web.extensions>
<scripting>
<webServices>
<jsonSerialization maxJsonLength="2147483647"/>
</webServices>
</scripting>
</system.web.extensions>
The issue was solved.
Upvotes: 2
Reputation: 30152
http://msdn.microsoft.com/en-us/library/aa528822.aspx There are limits by default.
<configuration> <system.web> <httpRuntime maxMessageLength="409600" executionTimeoutInSeconds="300"/> </system.web> </configuration>
Upvotes: 1