拟发http请求处理响应


            string data = "Name=zhoulq&Sex=" + HttpUtility.UrlEncode("");
            byte[] msg=Encoding.UTF8.GetBytes(data);
            HttpWebRequest req = HttpWebRequest.Create("http://localhost:1256/Accept.aspx") as HttpWebRequest;
            req.ContentType = "application/x-www-form-urlencoded";
            req.ContentLength = msg.Length;
            req.Method = "POST";
            using (Stream stream=req.GetRequestStream())
            {
                stream.Write(msg, 0, msg.Length);
            }
            using (HttpWebResponse rsp = req.GetResponse() as HttpWebResponse)
            {
                Stream stream=rsp.GetResponseStream();
                StreamReader sr = new StreamReader(stream,Encoding.UTF8);
                lta.Text = sr.ReadToEnd();
                sr.Close();
                stream.Close();
            }


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM