string url = @"https://www.baidu.com"; //向指定服务器发起请求 HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(url); //request.Proxy = null; HttpWebResponse response = (HttpWebResponse)request.GetResponse(); //获取响应内容长度 long contentLength = response.ContentLength; //获取响应内容格式 string contentType = response.ContentType; //获取服务器返回的响应流 Stream receiveStream = response.GetResponseStream(); //使用指定的编码创建文本读取流 StreamReader readStream = new StreamReader(receiveStream, Encoding.UTF8); //读取响应内容 string contentText = readStream.ReadToEnd(); //关闭流 response.Close(); readStream.Close();