1

I am creating an application that uses a 3rd party payment gateway. I submit my transaction details, and the documentation says that:

The following fields will be supplied to the return script using the POST method:

So, the 3rd party payment gateway POSTs to a url i specify... how can i get the values of the POST request on this page?

4 Answers 4

4

You will be able to get these values through the Request.Form collection. For example, Request.Form["transactionId"].

Sign up to request clarification or add additional context in comments.

Comments

2

If it sends key value pairs like in the query string format, you can use Request.Form to read it. Otherwise to get raw POST content try:

Request.BinaryRead

Comments

0

When you say "on this page" are you referring to the page that the payment gateway was setup to POST to, or are you asking how to reference that information on a different page, such as the one that your user is on?

Comments

0

Try this:

    NameValueCollection coll = Request.Form;
    foreach (var key in coll.AllKeys)
    {
        Response.Write(key + ": " + coll[key] + "<br/>");
    }

And insert it into Page_Load on the page the 3rd party gateway posts to. This loops through all the keys and prints out their value.

2 Comments

Ahem, that isn't exactly useful. You see, you're writing content to a response that's returned to the source of the request, which in this case is the 3rd party gateway. You never get to see the contents of the response your page sends back, unless it is your browser that sends the POST request to the page.
That's true, so substitute Response.Write with something else e.g. log it to a file.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.