c#jquery对象引用未设置为对象的实例

我在c#中有一个web服务,我从我的jquery脚本调用它。

这是c#中的web服务

[WebMethod] [ScriptMethod(UseHttpGet = true)] public void LoadService2Daily(string fromDate, string toDate, string[] campaigns) 

在脚本中我这样做:

 var selectedCampaigns = $("#campaignDiv input:checkbox:checked").map(function () { return $(this).val(); }).get(); console.log(selectedCampaigns); webServiceUrl = 'http://localhost:4025/vmp_webservice.asmx/LoadService2Daily'; $.getJSON(webServiceUrl, { fromDate: valFrom, toDate: valTo, campaigns: selectedCampaigns }) .done(function (result) { 

我收到错误500 ,当我检查响应时,它是对象引用未设置对象的实例。

注意

如果我从Web服务中删除了string[] array ,它可以正常工作,但是当我添加它时,它会停止工作。 所以我确定这是因为string array事情,但我不知道错误究竟在哪里。

没有数组的代码已经工作了3年没有任何问题,但现在我正在进行一些编辑,我需要传递该数组。

这是console.log的屏幕截图,用于打印selectedCampgains。 请注意,正如我在代码中向您展示的那样,此日志是在调用Web服务之前获取的

在此处输入图像描述

编辑

我注意到网络服务的url是

 Request URL:http://localhost:4025/vmp_webservice.asmx/LoadService2Daily?fromDate=2014-05-25+00%3A00%3A00&toDate=2014-05-25+23%3A59%3A01&campaigns%5B%5D=default&campaigns%5B%5D=Support 

因为它不包含字符串数组,对吧?

EDIT3

这是我得到的完整例外

 System.NullReferenceException: Object reference not set to an instance of an object. at System.Web.Services.Protocols.ValueCollectionParameterReader.Read(NameValueCollection collection) at System.Web.Services.Protocols.UrlParameterReader.Read(HttpRequest request) at System.Web.Services.Protocols.HttpServerProtocol.ReadParameters() at System.Web.Services.Protocols.WebServiceHandler.CoreProcessRequest() 

生成的URL有方括号,请你检查这是否可以没有方括号,即没有%5B和%5D(没有url编码)

 http://localhost:4025/vmp_webservice.asmx/LoadService2Daily?fromDate=2014-05-25+00%3A00%3A00&toDate=2014-05-25+23%3A59%3A01&campaigns=default&campaigns=Support