Jquery 部署到AppHarbor后,WebInvoke表单元素为空
我使用Jquery发布WCF服务 它在我的开发环境中运行良好,但是发布的值在部署到AppHarbor的服务器上无法检索 服务的定义如下:Jquery 部署到AppHarbor后,WebInvoke表单元素为空,jquery,wcf,appharbor,Jquery,Wcf,Appharbor,我使用Jquery发布WCF服务 它在我的开发环境中运行良好,但是发布的值在部署到AppHarbor的服务器上无法检索 服务的定义如下: [OperationContract] [WebInvoke(Method="POST", UriTemplate="/RunReport/MyReport", RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json)] WebResults MyReport(
[OperationContract]
[WebInvoke(Method="POST", UriTemplate="/RunReport/MyReport", RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json)]
WebResults MyReport();
public WebResults MyReport()
{
var value = HttpContext.Current.Request.Form["formName"];
...
}
在实现中,我得到如下值:
[OperationContract]
[WebInvoke(Method="POST", UriTemplate="/RunReport/MyReport", RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json)]
WebResults MyReport();
public WebResults MyReport()
{
var value = HttpContext.Current.Request.Form["formName"];
...
}
实现类还具有以下属性:
[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Required)]
正如我所说,这在本地运行良好,我可以看到Firebug中的jquery发布了正确的数据,但由于某些原因,AppHarbor HttpContext.Current.Request.Form[“formName”]总是返回NULL
有什么想法吗?我不确定问题出在哪里,但我找到了一个解决办法 我现在使用以下代码,它似乎可以工作:
StreamReader reader = new StreamReader(stream);
String res = reader.ReadToEnd();
NameValueCollection coll = HttpUtility.ParseQueryString(res);
criteria.Retailers= coll["Retailers"].Split('|');
我在这篇帖子上找到了答案: