Winform uses Post to open IE, and winformpost to open ie

Source: Internet
Author: User

Winform uses Post to open IE, and winformpost to open ie

1. Main Implementation Code

1 void OpenNewIe (string url, string postData) // The url is the url for post and postData is the parameter 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 transfer

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         }

 

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.