post data through httpWebRequest

前端 未结 5 1285
情话喂你
情话喂你 2020-12-08 22:42

I need to \"Post\" some data to an external website using HttpWebRequest object from my application(desktop) and get a response back into my application through

5条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-08 23:37

    You could et those names by XPath e.g. and user them like:

    byte[]  data = new ASCIIEncoding().GetBytes("textBoxName1=blabla");
    HttpWebRequest httpWebRequest = (HttpWebRequest)WebRequest.Create("http://localhost/myservlet");
    httpWebRequest.Method = "POST";
    httpWebRequest.ContentType = "application/x-www-form-urlencoded";
    httpWebRequest.ContentLength = data.Length;
    Stream myStream = httpWebRequest.GetRequestStream();
    myStream.Write(data,0,data.Length);
    myStream.Close();
    

提交回复
热议问题