.NET Framework - Streaming PDF, measuring response timing

Asked By Ron
21-Nov-09 06:50 AM
Dear all

I have an asp.net application that streams PDFs to the browser in 64kb
chunks, looping through until all the PDF is streamed out. Here is a few lines
to help you get the picture (at bottom of this post)

My question is that I am going to measure the time that this code takes to
run and log it to see how things are performing. However, what will this
measurement actually be representing?

a) The time it takes for the whole data of the PDF to reach the client.
b) same as a) but additional time it takes for the Adobe Reader to load and
display (which is usually slow)
c) Something else, i'm missing the point?

Any help of thoughts greatly appreciated here! Thanks all.

ps. if the answer is b) is it actually possible to measure a)?


Response.Clear();
Response.Buffer = true;
Response.ContentType = "application/pdf";
Response.AddHeader("content-length", System.Convert.ToString(document.Size));
Response.AddHeader("Accept-Header", System.Convert.ToString(document.Size));

byte[] buffer = new byte[documentStreamer.BlobBufferSize];

while ((buffer = documentStreamer.StreamBytes()).Length != 0)
{
//Write straight back to browser....
Response.OutputStream.Write(buffer, 0, buffer.Length);
Response.Flush();
}
documentStreamer.Close();
Response.End();
Response.OutputStream.Write
(1)
Adobe
(1)
Response.ContentType
(1)
Response.AddHeader
(1)
ASP.NET
(1)
DocumentStreamer.BlobBufferSize
(1)
IIS
(1)
Response.Buffer
(1)
  bruce barker replied to Ron
21-Nov-09 02:39 PM
asp.net runs in a separate process from iis, and talks via a named pipe
to iis. you will measure how long it takes IIS to accept the data.
depending on how much IIS buffers, how much the internet buffers, how
much the proxies buffer, how much the firewalls buffer, etc will
introduce a difference between your measurement and what the browser sees.


-- bruce (sqlwork.com)
  Ron replied to bruce barker
22-Nov-09 02:36 PM
Hi Bruce, thanks for taking the time to reply

Just so I understand then, when this code finishes, the data could still be
on its way to the client and the PDF may not actually be visible yet?
  Andrew Morton replied to Ron
23-Nov-09 05:55 AM
It seems to me that using Fiddler and/or the time-taken field in the IIS log
files may give you the statistic you are looking for.

Notes on time-taken:
http://blog.jonathanroussel.com/2009/03/iis-5-and-6-time-taken-information.html

Fiddler:
http://www.fiddler2.com/fiddler2/

To see if the Adobe Reader plugin is being slow, you could try a different
one, like Foxit Reader.

Andrew
  Mark Rae [MVP] replied to Andrew Morton
23-Nov-09 06:42 AM
That's an excellent suggestion, IMO.

The Foxit reader outperforms the Adobe reader many times over, has virtually
none of the Adobe "bloat", and supports an MDI interface:
http://www.foxitsoftware.com/downloads/index.php


--
Mark Rae
ASP.NET MVP
http://www.markrae.net
  Ron replied to Mark Rae [MVP]
23-Nov-09 12:35 PM
Nice one gentlemen
Create New Account
help
size into the response header Response.AddHeader("Content-Length", Proc.Length.ToString()) ' Set the ContentType Response.ContentType = "application / octet-stream" ' Write the document into the response While dataLengthToRead > 0 AndAlso Response.IsClientConnected Dim lengthRead As Int32 = ms.Read(buffer, 0, blockSize) Response.OutputStream.Write(buffer, 0, lengthRead) 'Response.Flush(); / / do not flush since BufferOutput = true dataLengthToRead = dataLengthToRead - lengthRead End True ReadPanel.Visible = False Catch ex As Exception End Try End Sub ASP.NET Discussions Response.OutputStream.Write (1) Adobe (1) Word (1) Response.ClearHeaders (1) Response.BufferOutput (1) Response.ClearContent (1) Response
Response.ContentType = "application / vnd.ms-excel" IGNORED! .NET Framework I have an application that worked well on IIS6. I moved it to IIS7, and response.contenttype is now ignored. my code ends with: Response.ContentType = "application / vnd.ms-excel" Response.Flush() Response.End() But the browser receives "application / octet-stream text, and FFOX propts to save. Why? :(( thanks ASP.NET Discussions System.IO.FileInfo (1) Response.ContentType (1) Response.AddHeader (1) Response.WriteFile (1) Server.UrlEncode (1) Server.MapPath (1) FileInfo (1
Response.ContentType not working ??? .NET Framework The following code just outputs to the browser, I want it doesnt work. . . . Sub Page_Load(Sender As Object, E As EventArgs) Page.EnableViewState = False Response.Clear() Response.ContentType = "application / vnd.ms-excel" Response.AddHeader("Content-Disposition", "attachment; filename = test.xls") Response.write("Adrian simple. Any help would be appreciated. Ade ASP.NET Discussions QWRyaWFuIFR1cm5lcg (1) Page.EnableViewState (1) Response.ContentType (1) Response.AddHeader (1) EventArgs (1) IIS (1) Response.Clear (1) Disposition (1) Where is a different browser if you cannot find where to reset that browser option. Andrew keywords: Response.ContentType, not, working, ??? description: The following code just outputs to the browser, I want it to
Response.contenttype not working ??? .NET Framework The following code just outputs to the browser, I want it doesnt work. . . . Sub Page_Load(Sender As Object, E As EventArgs) Page.EnableViewState = False Response.Clear() Response.ContentType = "application / vnd.ms-excel" Response.AddHeader("Content-Disposition", "attachment; filename = test.xls") Response.write("Adrian Page.EnableViewState (1) Response.AddHeader (1) EventArgs (1) Response.Clear (1) Disposition (1) AddHeader (1) Response.contenttype (1) Response.write (1) I xls") For me it works. It must be a cache in your browser keywords: Response.contenttype, not, working, ??? description: The following code just outputs to the browser, I want it to