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

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)