Solved

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

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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

This article discusses the ASP.NET AJAX ModalPopupExtender control. In this article we will show how to use the ModalPopupExtender control, how to display/show/call the ASP.NET AJAX ModalPopupExtender control from javascript, how to show/display/cal…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

733 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