I am looking for a way to get the number of bytes sent to a specific point in an ASP.NET 2.0 response so that I can write that number in the response. Sort of:
Page.aspx:
<script runat="server">
private string GetResponseSize()
{
int nCurrentResponseSize = ...;
return ( nCurrentResponseSize.ToString() );
}
</script>
<html>
<head runat="server"><title>test</title></head>
<body>
<div>Size 1: <%= GetResponseSize() %></div>
<br />
<div>Size 2: <%= GetResponseSize() %></div>
</body>
</html>
The problem is that it is HttpResponse.OutputStream.Lengthnot supported ( NetworkStream does not support it).
I could implement HtmlTextWriterto override the default value and count bytes, but something inside ASP.NET should already have a counter and I'm trying to figure out if this is possible.
What I would like to avoid are solutions that include getting all the data and then parsing it to a specific point to find the size to that point. Until now, only such solutions have appeared in most of my searches.