当前位置: 编程技术>.net/c#/asp.net
asp.net输出重写压缩页面文件的实例
来源: 互联网 发布时间:2014-08-30
本文导语: asp.net输出重写压缩页面文件的例子,代码如下: 代码示例: using System; using System.Data; using System.Configuration; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using...
asp.net输出重写压缩页面文件的例子,代码如下:
代码示例:
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.htmlControls;
using System.Text.RegularExpressions;
using System.IO;
///
/// PageBase 页面基类
///
public class PageBase : System.Web.UI.Page
{
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 v]“, “”);
html = Regex.Replace(html, ” {2,}”, ” “);
html = Regex.Replace(html, “>[ ]{1}”, “>”);
writer.Write(html);
}
}
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.htmlControls;
using System.Text.RegularExpressions;
using System.IO;
///
/// PageBase 页面基类
///
public class PageBase : System.Web.UI.Page
{
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 v]“, “”);
html = Regex.Replace(html, ” {2,}”, ” “);
html = Regex.Replace(html, “>[ ]{1}”, “>”);
writer.Write(html);
}
}