码迷,mamicode.com
首页 > 其他好文 > 详细

后台post

时间:2017-08-31 18:03:05      阅读:168      评论:0      收藏:0      [点我收藏+]

标签:form   sts   com   ade   []   asc   sbo   enc   address   

抄来的例子

string url = "http://wx.sysmex.com.cn:8080/Utility/AddressBookSync.aspx";
                    string postData = "method=sync";

      postData+="&data2=xxx";

                    ASCIIEncoding encoding = new ASCIIEncoding();
                    byte[] data = encoding.GetBytes(postData);
                    HttpWebRequest myRequest = (HttpWebRequest)WebRequest.Create(url);

                    myRequest.Method = "POST";
                    myRequest.ContentType = "application/x-www-form-urlencoded";
                    myRequest.ContentLength = data.Length;
                    Stream newStream = myRequest.GetRequestStream();

                    newStream.Write(data, 0, data.Length);
                    newStream.Close();

                    HttpWebResponse myResponse = (HttpWebResponse)myRequest.GetResponse();
                    StreamReader reader = new StreamReader(myResponse.GetResponseStream(), Encoding.Default);
                    string content = reader.ReadToEnd();
                    reader.Close();

后台post

标签:form   sts   com   ade   []   asc   sbo   enc   address   

原文地址:http://www.cnblogs.com/forekoy/p/7459356.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!