如何直接在具有发布数据的浏览器中打开页面

时间:2014-04-18 07:26:46

标签: c# .net post

我们可以直接在浏览器中使用查询字符串(GET数据)打开页面。 有没有办法直接在有POST DATA的浏览器中打开页面。

1 个答案:

答案 0 :(得分:0)

使用WebBrowser控件打开包含帖子数据的网址:

  string url = "http://example.com";  
  string postData = "param1=value1&param2=value2&param3=value3";
  byte[] Post = Encoding.UTF8.GetBytes(postData );  
  string AdditionalHeaders = "Content-Type: application/x-www-form-urlencoded";  
  //wbSample is the web browser control  
  //the WebNavigate method is just a simple method i created  
  //which simply assigns url to the browser, the post data and additional headers  
  WebNavigate(wbSample , ListURL, "", Post, AdditionalHeaders);