调用这个方法,你可以将动态的asp.net页面,保存为静态htm文件。
string url=http://www.csdn.net/fly.aspx?id=515225;
GetPageHtml(url);
private String GetPageHtml(string url)
{
String Result;
WebResponse MyResponse;
WebRequest MyRequest = System.Net.HttpWebRequest.Create(url);
MyResponse = MyRequest.GetResponse();
using (StreamReader MyReader = new StreamReader(MyResponse.GetResponseStream(),System.Text.Encoding.Default))
{
Result = MyReader.ReadToEnd();
MyReader.Close();
}
FileStream fs = new FileStream("c:\\flystudio.htm",FileMode.Create,FileAccess.Write);
StreamWriter sw = new StreamWriter(fs,System.Text.Encoding.Default);
sw.WriteLine(Result);
sw.Close();
fs.Close();
return Result;
}
解释请查看vs.net自带的msdn......
:)flystudio@2911.net