Is there a better approach to minify html generated from aspx page
- by Hoque
I am using the following code to minify html generated from aspx page duuring runtime.
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);
}
Is there more better approach to do the same.
Thank you so much.