如何获取http的response内容

2025-05-17 10:22:42
推荐回答(1个)
回答(1):

HttpWebResponse response = (HttpWebResponse)webRequest2.GetResponse();
Stream myResponseStream = response.GetResponseStream();
StreamReader myStreamReader = new StreamReader(myResponseStream, Encoding.GetEncoding("UTF-8"));
string retString = myStreamReader.ReadToEnd();
myStreamReader.Close();
myResponseStream.Close();
//返回:服务器响应流
return retString;

试试这个。