您的位置:首页 > 理论基础 > 计算机网络

HttpWebRequest && WebResponse

2016-06-06 21:39 543 查看
public class Program
{
public static void Main(string[] args)
{
RequestData("http://www.baidu.com");

Console.ReadLine();
}

public static async void RequestData(string uri)
{
HttpWebRequest httpWebRequest = WebRequest.CreateHttp(uri);
WebResponse webResponse =await httpWebRequest.GetResponseAsync();

Stream stream = webResponse.GetResponseStream();
StreamReader sr = new StreamReader(stream, System.Text.Encoding.UTF8);

Console.Write(sr.ReadToEnd());

}
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: