Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

Redirect to a PageA using PageA's html?

Options
  • 02-09-2009 12:15pm
    #1
    Closed Accounts Posts: 20


    This may be a strange question, here goes:

    I am constructing a post message which is being sent to paypal. I am using this class to achieve this:

    http://geekswithblogs.net/rakker/archive/2006/04/21/76044.aspx

    This is the code I use to send the post:
                PostSubmitter post = new PostSubmitter();
                post.Url = "https://www.sandbox.paypal.com/cgi-bin/webscr";
                post.PostItems.Add("cmd", "_s-xclick");
                post.PostItems.Add("hosted_button_id", "1054169");
                post.Type = PostSubmitter.PostTypeEnum.Post;
                string result = post.Post();
    
                Common.DisplayError(result, ref lblErrorMsg);
    

    This is working, my issue though is that I should be getting redirected to the paypal page. Instead I am being sent back the html markup of the page I should be redirecting to, below is the html that I get back in the result string:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <!--
             Script info: script: webscr, cmd: _s-xclick, template: p/wel/sandbox-outside, date: Aug. 26, 2009 11:29:22 PDT; country: US, language: en_US, xslt server: 
            web version: 59.0-1031221 branch: AHOD_590_0828_int
            content version: -
            pexml version: 59.0-1035464
            page XSL: Merchant/default/en_US/homepage/SandBox-outside.xsl
           hostname : EoKS8v2J16h1Ts4C-TeAlnIhpz-GaNaATNBT6oy6Vv4
             rlogid : EoKS8v2J16h1Ts4C%2bTeAlhMcNYt%2b342RufU4H8AEwod7ejqGfmkUJA%3d%3d_1237a564a66
    -->
    <title>Welcome - PayPal</title>
    <!--googleoff: all-->
    <meta name="description" content="PayPal is the safer, easier way to pay online without revealing your credit card number.">
    <!--googleon: all-->
    <link media="screen" rel="stylesheet" type="text/css" href="https://www.sandbox.paypal.com/WEBSCR-590-20090827-1/css/core/xptdev.css">
    <link media="screen" rel="stylesheet" type="text/css" href="https://www.sandbox.paypal.com/WEBSCR-590-20090827-1/css/core/global.css">
    <!--[if IE 7]><link media="screen" rel="stylesheet" type="text/css" href="https://www.sandbox.paypal.com/WEBSCR-590-20090827-1/css/browsers/ie7.css"><![endif]-->
    
    <!--[if lte IE 6]><link media="screen" rel="stylesheet" type="text/css" href="https://www.sandbox.paypal.com/WEBSCR-590-20090827-1/css/browsers/ie6.css"><![endif]-->
    <link rel="stylesheet" type="text/css" href="https://www.sandbox.paypal.com/WEBSCR-590-20090827-1/css/sandbox.css">
    <link media="print" rel="stylesheet" type="text/css" href="https://www.sandbox.paypal.com/WEBSCR-590-20090827-1/css/core/print.css">
    <script type="text/javascript">
    if (parent.frames.length > 0){
        top.location.replace(document.location);
    }</script><script type="text/javascript" src="https://www.sandbox.paypal.com/WEBSCR-590-20090827-1/js/lib/min/global.js"></script><link rel="shortcut icon" href="https://www.sandbox.paypal.com/WEBSCR-590-20090827-1/en_US/i/icon/pp_favicon_x.ico">
    <link rel="apple-touch-icon" href="https://www.sandbox.paypal.com/WEBSCR-590-20090827-1/en_US/i/pui/apple-touch-icon.png">
    </head>
    <body class="xptSandbox">
    <noscript><p class="nonjsAlert">NOTE: Many features on the PayPal Web site require Javascript and cookies. You can enable both via your browser's preference settings.</p></noscript>
    <div class="" id="page">
    <div id="content">
    <div id="headline">
    <h2 class="accessAid">Welcome</h2>
    </div>
    <div id="messageBox"></div>
    <div id="main"><div class="layout1">
    <p><img src="https://www.sandbox.paypal.com/WEBSCR-590-20090827-1/en_US/i/logo/logo_sandbox_clr_289x39.gif" border="0" alt=""></p>
    <p align="center"><strong>Please login to use the <a href="https://developer.paypal.com/">PayPal Sandbox</a> features.</strong></p>
    </div></div>
    </div>
    <div id="navFull"><ul>
    <li><a href="https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_home-general&amp;nav=0" class="scTrack:SRD:Nav:L5">Home</a></li>
    <li><a href="https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_home-customer&amp;nav=1" class="scTrack:SRD:Nav:L8">Personal</a></li>
    <li><a href="https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_home-merchant&amp;nav=2" class="scTrack:SRD:Nav:O3">Business</a></li>
    <li><a href="https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_products-services-outside&amp;nav=3" class="scTrack:SRD:Nav:S9">Products &amp; Services</a></li>
    <li><a href="https://www.paypal.com/shopping_outside" class="scTrack:SRD:Nav:k89">Shopping</a></li>
    </ul></div>
    <script type="text/javascript">if(typeof PAYPAL != 'undefined'){ PAYPAL.core.Navigation.init(); }</script>
    </div>
    <script type="text/javascript" src="https://www.sandbox.paypal.com/WEBSCR-590-20090827-1/js/pp_naturalsearch.js"></script><script type="text/javascript">mp_landing();</script>
    <!-- SiteCatalyst Code
    Copyright 1997-2005 Omniture, Inc.
    More info available at http://www.omniture.com -->
    <script type="text/javascript" src="https://www.sandbox.paypal.com/WEBSCR-590-20090827-1/js/site_catalyst/pp_jscode_paypalsandboxdev.js"></script>
    <script type="text/javascript">
    <!--
    /* SiteCatalyst Variables */
    s.prop1="p/wel/sandbox-outside";
    s.prop7="Unknown";
    s.prop8="Unknown";
    s.prop9="Unknown";
    s.prop10="US";
    s.prop34="PayPalCredit:Servicing:CO:NoTransactions";
    s.pageName="p/wel/sandbox-outside::_s-xclick";
    s.prop50="en_US";
    s.prop18="";
    /************* DO NOT ALTER ANYTHING BELOW THIS LINE ! **************/
    var s_code=s.t();if(s_code)document.write(s_code)//--></script>
    <script type="text/javascript"><!--
    if(navigator.appVersion.indexOf('MSIE')>=0)document.write(unescape('%3C')+'\!-'+'-')
    //-->
    </script><noscript><img
    src="//paypal.112.2O7.net/b/ss/paypalsandboxdev/1/H.6--NS/0?pageName=NonJavaScript"
    height="1" width="1" border="0" alt="" /></noscript>
    <!--/DO NOT REMOVE/-->
    
    <!-- End SiteCatalyst Code -->
    </body>
    </html>
    

    How can I make it so that I get redirected to the page, instead of getting its markup, or could I use this markup to get to the page?

    I was using a form post to achieve this in testing, paypal supplies 'Buy Now' buttons, but IE does not allow nested forms, and I have a form in my master page which must stay, so I have to somehow submit this post without using a form on my page.

    Hope this all makes sense :o

    Cheers for any help


Comments

  • Registered Users Posts: 21,257 ✭✭✭✭Eoin


    Off the top of my head, I don't see anything in the code that would redirect you. It looks like it's doing what it should: executing a post on a remote server and giving you back the results. I think it's effectively screen scraping.


  • Closed Accounts Posts: 580 ✭✭✭karlr42


    Er, the program works perfectly. The HTML you're getting back is the page. I'm not quite sure what environment you're running this in- if it's some kind of IDE or the command line, just add some more code to save the html to a file and then open that file with a web browser.
    EDIT: As Eoin said, this program isn't designed to redirect you, it executes the post and then gives back the html response, which you can use to verify things went smoothly by saving and opening it with a browser.


  • Registered Users Posts: 21,257 ✭✭✭✭Eoin


    karlr42 wrote: »
    Er, the program works perfectly. The HTML you're getting back is the page. I'm not quite sure what environment you're running this in- if it's some kind of IDE or the command line, just add some more code to save the html to a file and then open that file with a web browser.

    No, I think he is expecting the browser to go to the page he is getting back - not just render it locally.

    He needs to find a way to submit the data from his own form to Paypal.

    Try this google search for starters:
    http://www.google.ie/search?hl=en&safe=off&client=firefox-a&rls=org.mozilla%3Aen-GB%3Aofficial&hs=PYo&q=aspx+submit+form+to+page+on+different+site&btnG=Search&meta=

    You might be able to use JavaScript to change the form action on the client side, but that's not really the most robust method.


  • Closed Accounts Posts: 20 Whackhead


    Thanks for the replies guys, I have come up with a simpler solution though. My problem was I couldn't have the PayPal 'Buy Now' form on the same page as my master page.

    So I added the form to a blank html page, added some script to submit the form on page load. Then on my purchase page I just redirect to this html page and the form is posted and I get redirected. Seems to work ok.

    Thanks again


  • Registered Users Posts: 21,257 ✭✭✭✭Eoin


    That's pretty much what I suggested last, you're just adding an extra page in the process.

    I know it's because of the lifecycle of an ASP.net page, but it would be great if you could just do something like this:

    form1.action = "customurl";

    You could use Server.Transfer as well, but I think it won't change the address in the title bar.


  • Advertisement
Advertisement