110,549
社区成员
发帖
与我相关
我的任务
分享
void Application_PostReleaseRequestState(object sender, EventArgs e)
{
Response.Filter = new MyFilter(Response.Filter);
}
class MyFilter : MemoryStream
{
Stream output = null;
public MyFilter(Stream output) { this.output = output; }
public override void Write(byte[] buffer, int offset, int count)
{
var html = Encoding.UTF8.GetString(buffer, offset, count);
int p = html.IndexOf("</body>");
if (p != -1)
{
html = html.Insert(p, "hello world.");
}
var buf = Encoding.UTF8.GetBytes(html);
output.Write(buf, 0, buf.Length);
}
}