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);
原文地址:https://www.cnblogs.com/webapi/p/4250609.html