how to get size of generated aspx page

T

TomislaW

I need page size of generated aspx page, how and when I can get this
information programmatically
 
S

S.M. Altaf [MVP]

There is an example given here:
http://www.quirksmode.org/js/filesize.html

But it'll work in IE and not FireFox. If you're trying to do this through
server side code on the same page, that'd be something of a paradoxical
infinite loop, since the code would need to check for the final size of the
page after it's been sent to the client, and not during generation.

HTH

-Altaf
 
J

Juan T. Llibre

re:
If you're trying to do this through server side code

That's what we do in this newsgroup, Altaf.

Client-side solutions which have not been modifed
for use within an ASP.NET page are of little interest.

If you have a solution for ASP.NET, please post it.
 
T

TomislaW

i need this on server side
you say that is not possible to calculate size of
Response.OutputStream!?
 
J

Juan T. Llibre

See an example at : http://asp.net.do/test/servervars.aspx

If you select CONTENT_LENGTH from the dropdown,
you'll see the correct document size ( 2672 bytes, in this case ).

The only problem is that I've tried to get this directly :

Request.ServerVariables("CONTENT_LENGTH")
and
Request.ContentLength ...and can't.

but I always get a content length of 0 if I do.

I think that the problem is that Request.ServerVariables only
includes the headers the client sends back to the server,
and not all the headers the server sends.

However, I don't understand why the example I used ( see link above ),
based on Microsoft-supplied code, *does* retrieve the correct value.

I'll have to check this out some more.
 
J

Juan T. Llibre

You might be able to with WebHttpRequest.




TomislaW said:
i need this on server side
you say that is not possible to calculate size of
Response.OutputStream!?
 
K

Kevin Spencer

An alternative is to put everything in the page inside a div, and set the
style of it to width:100%;height:100%. Then you can use the offsetWidth
property and offsetHeight property of the div to get the width and height of
the page, using JavaScript. This should work in all browsers.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
A watched clock never boils.
 
K

Kevin Spencer

Ah, sorry.

--

Kevin Spencer
Microsoft MVP
..Net Developer
A watched clock never boils.
 
B

Bruce Barker

the easiest is the iis logs. you can even set up iis to write them to a
sqlserver database and do queries.

-- bruce (sqlwork.com)
 
J

Juan T. Llibre

That works, alright.

I think he wanted to do that on-the-fly, though.
That might prove to be a bit more difficult.

I know that, on a postback, you can get it from Request.ServerVariables,
but am unsure how to do it any other way on-the-fly.
 
J

John Timney \( MVP \)

You may well be able to do it via an ihttpmodule response filter, as it
passes the binary stream into the filter, and you could use sizeOf or some
appropriate method to find the size of the byte stream. I cant remember
however if the headers have been added at this point or not, I guess it
depends where you invoke the filter.

--
Regards

John Timney
ASP.NET MVP
Microsoft Regional Director
 
S

S.M. Altaf [MVP]

You don't consider JavaScript to be part of the "ASP.NET model"? That's
surprising.
 
J

Juan T. Llibre

If your solution had been custom-tailored for
use in an ASP.NET environment, then yes.

As you well, know, inserting JavaScript in ASP.NET
cannot be done by simply writing it into the page.

There's some tweaking that has to be done, like registering
the script and changing the way that the string is written.

Simply throwing a Javascript script at a beginning ASP.NET
programmer, like the ones who mostly wander in here, is not
offering a viable solution which they can use.

Like I said, if you have a solution for ASP.NET, please post it,
or post a link to where a viable solution can be found.

I have a feeling that the solution you posted
does not work if used within ASP.NET, anyway.

Did you verify that it does work in ASP.NET ?

( After modifying the way the script is written,
so that it can be inserted in an ASPX page ?)





S.M. Altaf said:
You don't consider JavaScript to be part of the "ASP.NET model"? That's surprising.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,020
Latest member
GenesisGai

Latest Threads

Top