//接收
Stream stream = HttpContext.Current.Request.InputStream
byte[] getByte = new byte[stream.Length]
stream.Read(getByte, 0, getByte.Length)
string postStr = Encoding.UTF8.GetString(getByte)
//请求
string url = ""
HttpWebRequest webrequest = (HttpWebRequest)HttpWebRequest.Create(url)
webrequest.Method = "post"
webrequest.ContentType = "application/json;charset=UTF-8"
byte[] postByte = Encoding.UTF8.GetBytes(postStr)
webrequest.ContentLength = postByte.Length
Stream stream1 = webrequest.GetRequestStream()
stream1.Write(postByte, 0, postByte.Length)
stream1.Close()
HttpWebResponse response
try
{
response = (HttpWebResponse)webrequest.GetResponse()
}
catch (WebException ex)
{
response = (HttpWebResponse)ex.Response
}
StreamReader sr = new StreamReader(response.GetResponseStream())
string getStr = sr.ReadToEnd()