C # Open Browser and POST submission information

Source: Internet
Author: User

In making payment jump to browser third party payment platform, then need to open and submit some information with the browser; There is no get method here, because the parameters are too exposed;

Of course, the important parameters are to be encrypted.

The normal way to invoke the browser is to open the Web page:

Call IE browser  System.Diagnostics.Process.Start ("Iexplore.exe", "http://g.cn");      Call the system default browser System.Diagnostics.Process.Start ("http://g.cn");   

Here I need to call IE to post some order form data, and then further jump to the payment platform:

Using the WebBrowser control, the Navigate method

1 //2 //Summary:3 //navigates asynchronously to the document at the specified System.Uri and specifies the target frame to which to load the document content. Other HTTP POST data and HTTP headers can be sent to the server as part of the navigation request. 4 //5 //Parameters:6 //Source:7 //the System.Uri to navigate to. 8 //9 //Targetframename:Ten //The name of the frame in which to display the document's contents.  One // A //PostData: - //The HTTP POST data to be sent to the server when the source is requested.  - // the //additionalheaders: - //The HTTP header to send to the server when the source is requested.  - // - //Exception: + //system.objectdisposedexception: - //The System.Windows.Controls.WebBrowser instance is no longer valid.  + // A //System.InvalidOperationException: at //failed to retrieve reference to base native WebBrowser.  - // - //System.Security.SecurityException: - //navigating from an application running in a non-fully trusted state: Navigating to a System.Uri or targetframename name that is not at the source site is not null or empty.  -  Public voidNavigate (Uri source,stringTargetframename,byte[] PostData,stringAdditionalheaders);

Note that the parameter targetframename needs to be specified as "_blank" so that the form information submitted in the form will be executed in the newly opened browser page:)

New WebBrowser (); 2 byte [] BODY = Encoding.UTF8.GetBytes ("name=test&password=123");  Browser. Navigate ("http://www.domain.com/login? " " _blank " " content-type:application/x-www-form-urlencoded "

C # Open Browser and POST submission information

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.