我正在使用以下代码来缩小运行时从 aspx 页面生成的 html。
protected override void Render(HtmlTextWriter writer)
{
TextWriter output = new StringWriter();
base.Render(new HtmlTextWriter(output));
String html = output.ToString();
html = Regex.Replace(html, @"\n|\t", " ");
html = Regex.Replace(html, @">\s+<", "><").Trim();
html = Regex.Replace(html, @"\s{2,}", " ");
writer.Write(html);
}
是否有更好的方法来做同样的事情。
非常感谢。
最佳答案
是的,通过使用 Html Tidy甚至 HTTP Module .
关于c# - 有没有更好的方法来缩小从 aspx 页面生成的 html,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3062898/