Hi
Based on my understanding, you want to retrieve the HTML from external web page and save it to file or display on the page.
There are the codes achrieving it, you can try it:
private void saveURL(string url)
{
if (!string.IsNullOrEmpty(url))
{
string content = "";
System.Net.WebRequest webRequest = WebRequest.Create(url);
System.Net.WebResponse webResponse = webRequest.GetResponse();
System.IO.StreamReader sr = new StreamReader(webResponse.GetResponseStream(), System.Text.Encoding.GetEncoding("UTF-8"));
content = sr.ReadToEnd();
//save to file
StreamWriter sw = new StreamWriter(Server.MapPath("webcontent.txt"));
sw.Write(content);
sw.Flush();
//display it in this page
Response.Write(content);
}
}
You can call the method like: saveURL("http://forums.asp.net/t/1201527.aspx"); Please pay attention on the format of URL, "http://" is necessary. Without it, you will encounter the error "The format of the URI could not be determined. "
You can get more information at: http://www.west-wind.com/presentations/dotnetWebRequest/dotnetWebRequest.htm
Hope this can help.