Winform uses Post to open IE

Source: Internet
Author: User

Winform uses Post to open IE
1. Mainly implement Code 1 void OpenNewIe (string url, string postData) // url is the url to post, and postData is the parameter to be passed in 2 {3 if (ie! = Null) // avoid opening the ie Object repeatedly without releasing it, and throw an exception 4 {5 try 6 {7 ie. quit (); 8} 9 catch10 {11 ie = null; 12} 13} 14 ie = new InternetExplorer (); 15 object vPost, vHeaders, vFlags, vTargetFrame; 16 vPost = Encoding. getEncoding ("GB2312 "). getBytes (postData); // Note whether the encoding method is GB2312 or ASCII17 vFlags = null; 18 vTargetFrame = null; 19 vHeaders = "Content-Type: application/x-www-form-urlencoded "+ Convert. toChar (10) + Convert. toChar (13); 20 ie. visible = true; 21 ie. navigate (url, ref vFlags, ref vTargetFrame, ref vPost, ref vHeaders); 23} 2. parameter passing 1 StringBuilder postData = new StringBuilder (); 2 postData. appendFormat ("uid = {0}", HelpEncrypt. encode (uid. toString (), key); 3 postData. appendFormat ("& serial_number = {0}", HelpEncrypt. encode (serial_number, key); 3. call method 1 if (checkBoxNo. checked) 2 {3 OpenNewIe (Parameter. payaddress, postData. toString (); 4} 4. additional: Use the WebBrowser component Post to open IE 1 private void TransferWebForm_Load (object sender, EventArgs e) 2 {3 string vHeaders = "Content-Type: application/x-www-form-urlencoded "+ Convert. toChar (10) + Convert. toChar (13); 4 byte [] vPost = Encoding. getEncoding ("GB2312 "). getBytes (_ postData); 5 this. webBrowser1.Navigate (navigateUrl, null, vPost, vHeaders); 6}

Related Article

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.