سؤال

I have WCF services that I post to with Jquery.

It works fine in my development environment, but the POSTed values are not retrieved on the server now it is deployed to AppHarbor.

The service is defined like this:

[OperationContract]
[WebInvoke(Method="POST", UriTemplate="/RunReport/MyReport", RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json)]
WebResults MyReport();

In the implementation I get the values like this:

public WebResults MyReport()
{
var value = HttpContext.Current.Request.Form["formName"];
...
}

The implementation class also has this attribute:

[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Required)]

As I said, this works fine locally, and I can see the correct data is being POSTed by jquery in Firebug, but for some reason on AppHarbor HttpContext.Current.Request.Form["formName"] always returns NULL.

Any ideas?

هل كانت مفيدة؟

المحلول

Well I'm not sure what the problem is, but I found a work-around...

I now use the following code and it seems to work:

StreamReader reader = new StreamReader(stream);
String res = reader.ReadToEnd();
NameValueCollection coll = HttpUtility.ParseQueryString(res);
criteria.Retailers= coll["Retailers"].Split('|');

I found the answer on this post: WCF + REST: Where is the request data?

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top