将动态aspx页面,保存为静态htm文件

来源:互联网 发布:cad签名制作软件 编辑:程序博客网 时间:2024/04/29 17:36
<script type="text/javascript"><!--google_ad_client = "pub-2947489232296736";/* 728x15, 创建于 08-4-23MSDN */google_ad_slot = "3624277373";google_ad_width = 728;google_ad_height = 15;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
<script type="text/javascript"><!--google_ad_client = "pub-2947489232296736";/* 160x600, 创建于 08-4-23MSDN */google_ad_slot = "4367022601";google_ad_width = 160;google_ad_height = 600;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>

  调用这个方法,你可以将动态的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

<script type="text/javascript"><!--google_ad_client = "pub-2947489232296736";/* 728x15, 创建于 08-4-23MSDN */google_ad_slot = "3624277373";google_ad_width = 728;google_ad_height = 15;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
<script type="text/javascript"><!--google_ad_client = "pub-2947489232296736";/* 160x600, 创建于 08-4-23MSDN */google_ad_slot = "4367022601";google_ad_width = 160;google_ad_height = 600;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
原创粉丝点击