打开浏览器并且发出post命令

System.Net.HttpWebRequest request2;
        request2 = (System.Net.HttpWebRequest)WebRequest.Create(Myurl);
        //Post请求方式
        request2.Method = "POST";
        // 内容类型
        request2.ContentType = "application/x-www-form-urlencoded";
        // 参数经过URL编码
           string paraUrlCoded = System.Web.HttpUtility.UrlEncode("SAMLRequest");
           paraUrlCoded += "=" + System.Web.HttpUtility.UrlEncode(RequenstCanshu);
        byte[] payload;
        //将URL编码后的字符串转化为字节
        payload = System.Text.Encoding.UTF8.GetBytes(paraUrlCoded);


        WebBrowser browser = new WebBrowser();

        browser.Navigate(accountSettings.idp_sso_target_url2, "_blank", payload, "Content-Type: application/x-www-form-urlencoded");

你可能感兴趣的:(打开浏览器并且发出post命令)