Solved

Determine page size (bytes sent) from code behind in ASP.NET 2.0 or later

Posted on 2011-03-02
4
591 Views
Last Modified: 2012-05-11
Greetings,

What is the correct way from code behind to determine the number of bytes sent to the client browser?

Background info:

We have a website written in Visual Basic using ASP.NET 4.0. We’re working on improving performance (time to load a page) of our site. Part of this will be to reduce the size of our pages as needed i.e. the number of bytes sent to the client machine.

First step is to get a better understanding of how large the pages are currently. Since our page size can vary significantly depending on user selections, we would like to sample real live data of what our customers are seeing. I understand that we can turn on Trace and get this information. However, we’re looking for a way to determine this from code behind for our users and do not want to turn on Trace. Determining this from code behind would allow us to capture the amount of bytes sent to the client and store it for later analysis.

We have been looking at the Page.Response object late in the page life cycle stage (such as Page_PreRenderComplete or Page_Unload event) but do not see any methods to determine the page size. Using response.Headers("Content-Length") gives an error of "This operation requeires IIS integrated pipeline mode". Is there a way to make it work in general with or without IIS?

What is the correct way from code behind to determine the number of bytes sent to the client browser?

Thanks,

Karsten
0
Comment
Question by:karstenweber
  • 2
  • 2
4 Comments
 
LVL 18

Expert Comment

by:Matthew Kelly
ID: 35032687
Are you using IIS? If so, you could analyze the IIS server logs, maybe writing a script to parse it out. One of the fields logged in server bytes sent.

0
 
LVL 18

Accepted Solution

by:
Matthew Kelly earned 250 total points
ID: 35032697
You may need to enable logging, or select the fields to log if you aren't doing so already: http://technet.microsoft.com/en-us/library/cc754702(WS.10).aspx
0
 

Assisted Solution

by:karstenweber
karstenweber earned 0 total points
ID: 35032964
Thanks for the feedback.

We are using IIS on the server but not on the development environment. If possible, i'm looking for a code behind solution so that I can capture several metrics (time to generate page, user id, account id etc) and store it in the database along with the page size. At the time I'm capturing and storing this information, the IIS log will not have been written yet for that entry.

Is there really no way for asp.net code behind to tell how big a page it is generating?!

Thanks!
0
 

Author Closing Comment

by:karstenweber
ID: 35829909
We ended up writing a javascript to determine approximate page size (through innerHTML) and sending that information back to the server. This also allowed us to estimate network transfer time to client. Thanks matthewstevenkelly for your input.
0

Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

I recently went through the process of creating a Calendar Control of events with the basis of using a database to keep track of the dates that are selectable, one requirement was to have the selected date pop-up in a simple lightbox.  At first this…
Today is the age of broadband.  More and more people are going this route determined to experience the web and it’s multitude of services as quickly and painlessly as possible. Coupled with the move to broadband, people are experiencing the web via …
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

746 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now