?
Solved

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

Posted on 2011-03-02
4
Medium Priority
?
599 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: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone 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

In this Article, I will provide a few tips in problem and solution manner. Opening an ASPX page in Visual studio 2003 is very slow. To make it fast, please do follow below steps:   Open the Solution/Project. Right click the ASPX file to b…
In .NET 2.0, Microsoft introduced the Web Site.  This was the default way to create a web Project in Visual Studio 2005.  In Visual Studio 2008, the Web Application has been restored as the default web Project in Visual Studio/.NET 3.x The Web Si…
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…

766 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