Post Data (Urgent)

Discussion in 'ASP .Net' started by Vishal, Jan 7, 2005.

  1. Vishal

    Vishal Guest

    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
     
    Vishal, Jan 7, 2005
    #1
    1. Advertising

  2. Vishal

    Chad Devine Guest

    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")
     
    Chad Devine, Jan 7, 2005
    #2
    1. Advertising

  3. Vishal

    vMike Guest

    "Vishal" <> wrote in message
    news:0bc501c4f4d4$3281d4b0$...
    > 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.
     
    vMike, Jan 7, 2005
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Vishal
    Replies:
    1
    Views:
    695
    Steve C. Orr [MVP, MCSD]
    Dec 21, 2004
  2. Vishal
    Replies:
    5
    Views:
    435
    Ken Dopierala Jr.
    Dec 28, 2004
  3. =?Utf-8?B?Z29yaWxsYQ==?=
    Replies:
    1
    Views:
    792
    Masudur
    May 25, 2007
  4. Hal Vaughan
    Replies:
    4
    Views:
    787
    Hal Vaughan
    Jan 14, 2008
  5. Replies:
    0
    Views:
    260
Loading...

Share This Page