C# angularjs和webmethod返回json

C# angularjs和webmethod返回json,c#,jquery,angularjs,json,web-services,C#,Jquery,Angularjs,Json,Web Services,当我使用jquery$ajax时,我以json的形式获取数据 但是当使用AngularHTTP服务时,我得到的响应是xml 这是我的两个代码(angular和jquery ajax) 这是我的web方法代码,返回json格式 [WebMethod] [System.Web.Script.Services.ScriptMethod(ResponseFormat = System.Web.Script.Services.ResponseFormat.Json)]

当我使用jquery$ajax时,我以json的形式获取数据 但是当使用AngularHTTP服务时,我得到的响应是xml

这是我的两个代码(angular和jquery ajax)

这是我的web方法代码,返回json格式

 [WebMethod]
    [System.Web.Script.Services.ScriptMethod(ResponseFormat = 

    System.Web.Script.Services.ResponseFormat.Json)]
        public tblCampaignCollection GetList()
        {
            tblCampaignCollection coll =  Campaign.AdminGetAll();

            return coll;
    }

您执行的请求不是真正的POST请求,我有一个类似的问题,如果您阅读console网络选项卡,您将看到它是GET请求

如果我想在服务中执行POST,我将执行以下操作:

function myService(xxxParam) {

      var request = $http({
        method: 'POST',
        headers: {"Content-Type": 'text/plain; charset=UTF-8'},
        url: serviceURL,
        data: {
          firstPostParam: "string",
          secondPostParam: 1,
          thirdPostParam: xxxParam
        }
      });
      return ( request.then(handleSuccess, handleError) );
    }
试一试

$http({
      method: 'POST',
      url: '/Landing/manage/WebService.asmx/GetList',
      headers: {
        "Content-Type": 'application/json; charset=UTF-8'
      },
      data: {
        dataType:  "json"
      }
    })...

我希望它能有所帮助。

添加数据:{dataType:“json”}解决我的问题
$http({
      method: 'POST',
      url: '/Landing/manage/WebService.asmx/GetList',
      headers: {
        "Content-Type": 'application/json; charset=UTF-8'
      },
      data: {
        dataType:  "json"
      }
    })...