2010-12-03 59 views

回答

2

可能是最接近的是:

WebRequest req = WebRequest.Create(url); // note this is IDisposable so 
             // should be in a "using" block, or 
             // otherwise disposed. 

,因为这将处理多种协议等,但如果你的意思HTTP - 我会用WebClient;它比HttpWebRequestWebRequest实现之一)简单得多。

如果你想要的是下载页面:

string s; 
using(var client = new WebClient()) { 
    s = client.DownloadString(url); 
}