1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
| string requestStream = "email=toto@yahoo.com&pass=titi";
HttpWebRequest test = (HttpWebRequest)WebRequest.Create("http://www.site.fr/inscription.php");
test.Method = WebRequestMethods.Http.Post;//connect_email, connect_pass
test.PreAuthenticate = true;
test.CachePolicy = new HttpRequestCachePolicy(HttpRequestCacheLevel.NoCacheNoStore);
test.UserAgent = "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US) AppleWebKit/525.19 (KHTML, like Gecko) Chrome/1.0.154.36 Safari/525.19";
test.Referer = "http://www.site.fr/inscription.php";
test.ContentType = "application/x-www-form-urlencoded";
test.Accept = "text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5";
test.Connection = "KeepAlive";
test.ServicePoint.Expect100Continue = false;
test.Proxy = null;
test.ContentLength = requestStream.Length;
StreamWriter testStream = new StreamWriter(test.GetRequestStream());
testStream.Write(requestStream);
testStream.Close();
//Get response
HttpWebResponse response = (HttpWebResponse)test.GetResponse();
StreamReader sr = new StreamReader(response.GetResponseStream());
String result = sr.ReadToEnd();
sr.Close();
Form2 f = new Form2(response.GetResponseStream());
f.ShowDialog();
//constructeur de form2
public Form2(Stream str)
{
InitializeComponent();
webBrowser1.ObjectForScripting = this;
webBrowser1.DocumentStream = str;
webBrowser1.Show();
} |
Partager