private string GetText()
{
string resultString = string.Empty;
HttpWebRequest request = HttpWebRequest.CreateHttp("http://www.baidu.com");
request.Method = "GET";
request.BeginGetResponse((IAsyncResult result) =>
{
HttpWebRequest webRequest = result.AsyncState as HttpWebRequest;
HttpWebResponse webResponse = (HttpWebResponse)webRequest.EndGetResponse(result);
Stream streamResult = webResponse.GetResponseStream();
StreamReader reader = new StreamReader(streamResult); //获取的返回值
resultString = reader.ReadToEnd();
streamResult.Close();
reader.Close();
}, request); return resultString;
}
04-10 05:52