0

I'm trying to implement a service Redsys payments on my .net website.

The payment is successful (data are sent by post) but when the POST data back to my website ( to confirm the payment ) and i try to retrieve them with:

Request.form string value = [ "name"]

the value is always empty

I tried to count how many are in Request.Form.Keys.Count and always gives me zero values.

In the vendor documentation it indicated that the variables may be collected with Request.form [ "name"] and I called them to ask why I do not get the data and they dont know why...so I'm desperate,

What may be due?


I have reviewed the header I get from the server ( width Request.Headers ) and have the following parameters. HttpMethod:: GET Requestype: GET and contentlength: 0 . My bank tell me that they response POST not GET... so it´s a mistery. May be the error is becouse that sendings are made from a https to a htttp ?

ChrisF
  • 134,786
  • 31
  • 255
  • 325
kuai
  • 1
  • 1
  • try posting a little more code around what you are doing, and perhaps a sample of the XML/webservice response. – Dave Feb 25 '16 at 19:15
  • I have reviewed the header I get from the server ( width Request.Headers ) and have the following parameters. HttpMethod:: GET Requestype: GET and contentlength: 0 . My bank tell me that they response POST not GET... so it´s a mistery. May be the error is becouse that sendings are made from a https to a htttp ? – kuai Feb 26 '16 at 22:23

1 Answers1

-2

You are receiving a POST without parameters. The parameters are in the content of the call.

You should read the content and get the values of each parameter:

[System.Web.Http.HttpPost]
public async Task<IHttpActionResult> PostNotification()
{
    string body = "";
    await
    Request.Content.ReadAsStreamAsync().ContinueWith(x =>
               {
                   var result = "";
                   using (var sr = new StreamReader(x.Result))
                   {
                       result = sr.ReadToEnd();
                    }
                    body += result;
               });

In body you can read the parameters (the order of them can change).

Ad23
  • 106
  • 1
  • 7
  • That is not how you read posted form data. Use the [appropriate constructs ](http://stackoverflow.com/questions/11593595/is-there-a-way-to-handle-form-post-data-in-a-web-api-controller), and certainly don't manually read the content as string and parse it that naively. Also, given the asp.net tag and talk about `Request.Form`, it's more likely that this is ASP.NET WebForms as opposed to MVC/WebAPI. – CodeCaster Mar 14 '16 at 17:21