码迷,mamicode.com
首页 > Web开发 > 详细

asp.net获取当前页面源码并生成静态页面

时间:2015-01-26 16:47:45      阅读:129      评论:0      收藏:0      [点我收藏+]

标签:

StringWriter stringWriter = new StringWriter();
HtmlTextWriter htmlWriter = new HtmlTextWriter(stringWriter);
this.Page.RenderControl(htmlWriter);
string html = stringWriter.GetStringBuilder().ToString();

string path = HttpContext.Current.Server.MapPath("~/cache/index.htm");
File.WriteAllText(path, html, System.Text.Encoding.Default);

 

asp.net获取当前页面源码并生成静态页面

标签:

原文地址:http://www.cnblogs.com/zhaozi/p/4250609.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!