这是一个简单的方法:
我目前正在通过 HttpModule 记录请求持续时间,我也想找出每个页面的字节数。
HttpContext.Current.Response.OutputStream.Length
抛出一个NotSupportedException
.
有什么简单的方法可以做到这一点?
这是一个简单的方法:
我目前正在通过 HttpModule 记录请求持续时间,我也想找出每个页面的字节数。
HttpContext.Current.Response.OutputStream.Length
抛出一个NotSupportedException
.
有什么简单的方法可以做到这一点?
我有一个实现流重写器的 HttpModule。它派生自 Stream 类。在我的 HttpModule 中,我有以下代码:
void app_PreRequestHandlerExecute(object sender, EventArgs e)
{
HttpResponse response = HttpContext.Current.Response;
response.Filter = new MyRewriterStream(response.Filter);
}
在流类中,我有以下代码覆盖了默认的 Write 方法:
public override void Write(byte[] buffer, int offset, int count)
{
string outStr;
outStr = UTF8Encoding.UTF8.GetString(buffer, offset, count);
//Do useful stuff and write back to the stream
}
您可以在第二点取字符串的长度