- //把sXmlMessage发送到指定的DsmpUrl地址上
- Encoding encode = System.Text.Encoding.GetEncoding("utf-8");
- byte[] arrB = encode.GetBytes(sXmlMessage);
- HttpWebRequest myReq = (HttpWebRequest)WebRequest.Create(DsmpUrl);
- myReq.Method = "POST" ;
- myReq.ContentType = "application/x-www-form-urlencoded";
- myReq.ContentLength = arrB.Length;
- Stream outStream = myReq.GetRequestStream();
- outStream.Write(arrB,0,arrB.Length);
- outStream.Close();
- //接收HTTP做出的响应
- WebResponse myResp = myReq.GetResponse();
- Stream ReceiveStream = myResp.GetResponseStream();
- StreamReader readStream = new StreamReader( ReceiveStream, encode );
- Char[] read = new Char[256];
- int count = readStream.Read( read, 0, 256 );
- string str = null;
- while (count > 0)
- {
- str += new String(read, 0, count);
- count = readStream.Read(read, 0, 256);
- }
- readStream.Close();
- myResp.Close();
asp.net post发送数据
最新推荐文章于 2024-04-27 21:29:36 发布