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 }