Solved

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

Posted on 2011-03-02
4
593 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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

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 …
IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.

815 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

8 Experts available now in Live!

Get 1:1 Help Now