使用MonoTouch从web服务检索JSON字符串的限制
我正在使用MonoTouch开发一个iOS应用程序。应用程序使用以下代码从web服务收集数据:使用MonoTouch从web服务检索JSON字符串的限制,json,web-services,xamarin.ios,Json,Web Services,Xamarin.ios,我正在使用MonoTouch开发一个iOS应用程序。应用程序使用以下代码从web服务收集数据: private static string getResult (string url) { string result; var request = HttpWebRequest.Create (url); request.ContentType = "application/json";
private static string getResult (string url)
{
string result;
var request = HttpWebRequest.Create (url);
request.ContentType = "application/json";
request.Method = "POST";
using (HttpWebResponse response = request.GetResponse() as HttpWebResponse)
{
if (response.StatusCode != HttpStatusCode.OK)
Console.Out.WriteLine("Error fetching data. Server returned status code: {0}", response.StatusCode);
using (StreamReader reader = new StreamReader(response.GetResponseStream()))
{
result = reader.ReadToEnd();
}
}
return result;
}
这可以正常工作,但是当从Web服务返回的json字符串达到一定大小时,请求返回时出现内部服务器错误500。我曾尝试在web浏览器中直接调用服务方法,这将按预期返回json字符串。为什么它不能与我的代码一起工作,有没有办法解决这个问题
更新:
我想这可能会解决我的问题:尝试增加服务请求的超时时间。您的服务必须超时,导致500个错误 也检查一下这个