Xamarin.ios Monotouch中的Webservice返回XML而不是JSON

Xamarin.ios Monotouch中的Webservice返回XML而不是JSON,xamarin.ios,httpwebrequest,Xamarin.ios,Httpwebrequest,我试图使用Monotouch通过HttpWebRequest对象获取JSON数据。它在IPhone模拟器中运行良好,我得到了JSON。但是,当我在设备中运行应用程序时,当调用web服务时,我总是返回XML而不是JSON 在IPhone上运行时,是否需要设置任何特定的配置参数才能将结果设置为JSON?我在iPhone5、ios 6上运行这个 这是我的密码 var request = HttpWebRequest.Create(String.Format (@"{0}/GetActiveProduc

我试图使用Monotouch通过HttpWebRequest对象获取JSON数据。它在IPhone模拟器中运行良好,我得到了JSON。但是,当我在设备中运行应用程序时,当调用web服务时,我总是返回XML而不是JSON

在IPhone上运行时,是否需要设置任何特定的配置参数才能将结果设置为JSON?我在iPhone5、ios 6上运行这个

这是我的密码

var request = HttpWebRequest.Create(String.Format (@"{0}/GetActiveProductCountAfterID/filter?minID={1}",baseUrl, lastProductNumberInDatabase));
Logger.Debug("Request URL is: " + request.RequestUri);
request.ContentType = @"application/json";  
request.Method = "GET";
try{
     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()))
        {
            string content = reader.ReadToEnd();
........
当我在模拟器中运行时,我得到的内容是一个整数。例如:3456

但当我在IPhone上运行它时,我会

<int xmlns="http://schemas.microsoft.com/2003/10/Serialization/">3456</int>
3456

通过将服务器端web服务设置为将json作为默认web服务来解决此问题。对于那些可能遇到相同问题的人,我要做的是将Json作为默认格式(在服务器中.Net WCF的web.config文件中)


如果您可以(私下)共享您服务的URL,请在中填写错误报告,如果是内部的,则来自模拟器和设备的网络跟踪(例如,使用Wireshark完成)(需要在服务器端完成)可能有助于我们了解出了什么问题。
<system.serviceModel>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" />
<standardEndpoints>
  <webHttpEndpoint>
    <standardEndpoint name="" helpEnabled="true"   defaultOutgoingResponseFormat="Json" />
  </webHttpEndpoint>
</standardEndpoints>