C#使用post提交http请求
生活随笔
收集整理的這篇文章主要介紹了
C#使用post提交http请求
小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
版權(quán)聲明:歡迎評論和轉(zhuǎn)載,轉(zhuǎn)載請注明來源。 https://blog.csdn.net/zy332719794/article/details/50517403 string strId = "guest";string strPassword= "123456";ASCIIEncoding encoding=new ASCIIEncoding();string postData="userid="+strId;postData += ("&password="+strPassword);byte[] data = encoding.GetBytes(postData);// Prepare web request...HttpWebRequest myRequest =(HttpWebRequest)WebRequest.Create("http://www.here.com/login.asp");myRequest.Method = "POST";myRequest.ContentType="application/x-www-form-urlencoded";myRequest.ContentLength = data.Length;Stream newStream=myRequest.GetRequestStream();// Send the data.newStream.Write(data,0,data.Length);newStream.Close();// Get responseHttpWebResponse myResponse=(HttpWebResponse)myRequest.GetResponse();StreamReader reader = new StreamReader(response.GetResponseStream(),Encoding.Default);string content = reader.ReadToEnd();Console.WriteLine(content);
總結(jié)
以上是生活随笔為你收集整理的C#使用post提交http请求的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: JMeter基础之-使用技巧
- 下一篇: C# 该行已经属于还有一个表 的解决方法