2012-12-06 48 views
0

我正在使用MonoTouch开发iOS应用程序。该应用程序从一个Web服务收集的数据,使用此代码:使用MonoTouch从Web服务检索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字符串。为什么它不适用于我的代码,是否有解决此问题的方法?

更新: 我想,这也许能解决我的问题:http://forums.iis.net/t/1176077.aspx/1

回答