Post Data (Urgent)

V

Vishal

Hello,

I am posting some credit card info to the payment
server via a similar code. My code is written in VB.NET
but uses the same approach. At the end however I do a
response.write(streamReader.ReadToEnd());

----------------------------------
string stringPost = Request.Form.ToString(); // remember a
post is essentially a string delimited in a special way
....

// Here typically you should accept the form elements
(e.g., Request.Form.Get("txn_id")) and store them in local
variables.
....
HttpWebRequest httpWebRequest = (HttpWebRequest)
WebRequest.Create("https://www.paypal.com/cgi-bin/webscr");
httpWebRequest.Method = "POST";
httpWebRequest.ContentLength = stringPost.Length + 21; //
length plus 21 because &cmd=_notify-validate is 21 chars
long
httpWebRequest.ContentType = "application/x-www-form-
urlencoded";
StreamWriter streamWriter = null;
streamWriter = new StreamWriter
(httpWebRequest.GetRequestStream());
stringPost = stringPost + "&cmd=_notify-validate";
streamWriter.Write(stringPost);
streamWriter.Close();
HttpWebResponse httpWebResponse = (HttpWebResponse)
httpWebRequest.GetResponse();
using (StreamReader streamReader = new StreamReader
(httpWebResponse.GetResponseStream()))
{
stringResult = streamReader.ReadToEnd();
streamReader.Close();
}
----------------------------------

Now my question is the following. I store some information
in the session which I need after the above has executed.
Unfortunaly the session variables do not exist. But when I
close this window and go to my basket then I can see all
information which are stored in the session. So the
session variables are not lost, but they are not
accessible in the result of the httpWebResponse. Is there
a way get my session variables work there too?

Please help me out with any suggestions. This is really
URGENT for me.

Thanks
 
C

Chad Devine

I don't see you calling any session variables in this code...

A session variable usually looks like this:
Session("SiteBgcolor") = "Blue"

Or, if you are trying call one it's just:
Color = Session("SiteBGcolor")
 
V

vMike

Vishal said:
Hello,

I am posting some credit card info to the payment
server via a similar code. My code is written in VB.NET
but uses the same approach. At the end however I do a
response.write(streamReader.ReadToEnd());

----------------------------------
string stringPost = Request.Form.ToString(); // remember a
post is essentially a string delimited in a special way
...

// Here typically you should accept the form elements
(e.g., Request.Form.Get("txn_id")) and store them in local
variables.
...
HttpWebRequest httpWebRequest = (HttpWebRequest)
WebRequest.Create("https://www.paypal.com/cgi-bin/webscr");
httpWebRequest.Method = "POST";
httpWebRequest.ContentLength = stringPost.Length + 21; //
length plus 21 because &cmd=_notify-validate is 21 chars
long
httpWebRequest.ContentType = "application/x-www-form-
urlencoded";
StreamWriter streamWriter = null;
streamWriter = new StreamWriter
(httpWebRequest.GetRequestStream());
stringPost = stringPost + "&cmd=_notify-validate";
streamWriter.Write(stringPost);
streamWriter.Close();
HttpWebResponse httpWebResponse = (HttpWebResponse)
httpWebRequest.GetResponse();
using (StreamReader streamReader = new StreamReader
(httpWebResponse.GetResponseStream()))
{
stringResult = streamReader.ReadToEnd();
streamReader.Close();
}
----------------------------------

Now my question is the following. I store some information
in the session which I need after the above has executed.
Unfortunaly the session variables do not exist. But when I
close this window and go to my basket then I can see all
information which are stored in the session. So the
session variables are not lost, but they are not
accessible in the result of the httpWebResponse. Is there
a way get my session variables work there too?

Please help me out with any suggestions. This is really
URGENT for me.

Thanks

This code looks like the backend code for paypal's ipn conversation. Paypal
posts a transaction to the page and your code sends a response back with
what they posted to you and adds some validate text and then they send a
command response back. Not sure were the session id would come into play.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,764
Messages
2,569,566
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top