?
Solved

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

Posted on 2011-03-02
4
Medium Priority
?
601 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 1000 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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

A quick way to get a menu to work on our website, is using the Menu control and assign it to a web.sitemap using SiteMapDataSource. Example of web.sitemap file: (CODE) Sample code to add to the page menu: (CODE) Running the application, we wi…
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…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…

649 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