HttpWebRequest request = (HttpWebRequest)WebRequest.Create(_url);
request.AllowAutoRedirect = true;
request.ServicePoint.Expect100Continue = false;
request.ProtocolVersion = HttpVersion.Version11;
request.Timeout = 20000;
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
Stream dataStream = response.GetResponseStream();
Encoding encodings = System.Text.Encoding.GetEncoding("utf-8");
string strLastRedirect = response.ResponseUri.ToString();
StreamReader reader = new StreamReader(dataStream, encodings);
string streamreader = reader.ReadToEnd();
response.Dispose();
request.Abort();
我的代码是这样的,但是streamReader返回" //看到了所有的比较"每次
答案 0 :(得分:0)
我不明白您的问题是什么,但我发现您的代码存在问题。以下行使用的dataStream3
未在上面的代码块中声明。
StreamReader reader = new StreamReader(dataStream3, encodings);
为了使其与此代码块对应,它应该引用dataStream
变量。
StreamReader reader = new StreamReader(dataStream, encodings);