VB NET - Post data to php and open the response on default browser (is. firefox)


  • Hello Guys,

    I have a code as below to send the POST data to PHP and get response to open the URL on WebBrowser, but I need to open the response URL on my default browser (ie. firefox), will you assist me the code to do that, thanks

        Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click
            Dim postData As String = ""
            Dim request As WebRequest = WebRequest.Create("http://localhost/transfer/process.php")
            request.Method = "POST"
            Dim byteArray As Byte() = Encoding.UTF8.GetBytes(postData)
            request.ContentType = "application/x-www-form-urlencoded"
            request.ContentLength = byteArray.Length
            Dim dataStream As Stream = request.GetRequestStream()
            dataStream.Write(byteArray, 0, byteArray.Length)
            Dim response As WebResponse = request.GetResponse()
            dataStream = response.GetResponseStream()
            Dim reader As New StreamReader(dataStream)
            Dim responseFromServer As String = reader.ReadToEnd()
            '        MsgBox(responseFromServer)
            WebBrowser1.DocumentText = responseFromServer
        End Sub

    Best Regards, Thagor

    Wednesday, March 15, 2017 7:50 AM

All replies

  • Hi Indra,

    Based on your description, you want to open the response URL on your default browser(IE,firefox), can you tell me that  responseFromServer is the URL that you got? If yes, you can use System.Diagnostics.Process.Start(responseFromServer ) to open on the default browser.

    Best Regards,

    Cherry Bu   

    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact

    Thursday, March 16, 2017 8:48 AM
  • Hi Cherry,

    Thank you for your help, I was try your code advice but I have an error as per image.

    And below is my php code for your perusal, please advice to check my code what is missing in there..

    if (isset($_POST['submit'])) {
        //Here we can use transfer url or sanbox url.
        $transfer_url = '';
        //Here we can used seller email id. 
        $customer_email = $_POST['custEmail'];
        //Here we can put item name. 
        $item_name = $_POST['itemName'];
        //Here we can put price item. 
        $amount_price = $_POST['amountPrice'];
        //here we can put cancle url when payment is not completed.
        $cancel_return = "http://".$_SERVER['HTTP_HOST'].'/transfer';
        //here we can put cancle url when payment is Successful.
        $success_return = "http://".$_SERVER['HTTP_HOST'].'/transfer/success.php';
        //transfer call this file for data
        $notify_url = "http://".$_SERVER['HTTP_HOST'].'/transfer/data.php';
        <div style="margin-left: 38%"><img src="images/ajax-loader.gif"/><img src="images/processing_animation.gif"/></div>
        <form name="myform" action="<?php echo $transfer_url;?>" method="post">
            <input type="hidden" name="business" value="<?php echo $customer_email;?>" />
            <input type="hidden" name="notify_url" value="<?php echo $notify_url;?>" />
            <input type="hidden" name="cancel_return" value="<?php echo $cancel_return;?>" />
            <input type="hidden" name="return" value="<?php echo $success_return;?>" />
            <input type="hidden" name="rm" value="2" />
            <input type="hidden" name="lc" value="" />
            <input type="hidden" name="no_shipping" value="1" />
            <input type="hidden" name="no_note" value="1" />
            <input type="hidden" name="currency_code" value="USD" />
            <input type="hidden" name="page_style" value="transfer" />
            <input type="hidden" name="charset" value="utf-8" />
            <input type="hidden" name="item_name" value="<?php echo $item_name;?>" />
            <input type="hidden" name="cbt" value="Back to Home" />
            <input type="hidden" value="_xclick" name="cmd"/>
            <input type="hidden" name="amount" value="<?php echo $amount_price;?>" />
            <script type="text/javascript">
        <?php }



    Thursday, March 16, 2017 9:22 AM