好记性不如烂笔头。

asp.net页面过滤所有换行符和多余空格

此方法存在一个小问题,页面如果写了js用了//注释,则js会失效,所以页面写了js不要使用//来注释

protected override void Render(HtmlTextWriter writer)      
 {         
  StringWriter sw = new StringWriter();          
  HtmlTextWriter htmlWriter = new HtmlTextWriter(sw);          
  base.Render(htmlWriter);          
  string html = sw.ToString();          
  html = Regex.Replace(html, "[\f\n\r\t\v]", "");          
  html = Regex.Replace(html, " {2,}", " ");          
  html = Regex.Replace(html, ">[ ]{1}", ">");          
  writer.Write(html);      
 }