Matthew Cole
Matthew Cole

Reputation: 1339

Running code upon Response.TransmitFile completion

I'm using Response.TransmitFile to retrieve a file from a web service. I'd like to measure the amount of time this process takes from the server's perspective.

I've tried grabbing the tick count before and after this call, but that clearly didn't represent how long the transfer took. It gave me back numbers like 0.0016 milliseconds for a 30 MB file. :-)

Any ideas?

Upvotes: 2

Views: 1463

Answers (1)

Cheeso
Cheeso

Reputation: 192487

The transfer is asynchronous, as you've seen.

You may be able to get what you want by turning off buffering in the HttpResponse (Response.Buffer = false) before calling TransmitFile. If that fails, then transmit it "manually" and synchronously, using FileStream.

If you only want to observe the time required for the transmission, just for your information, and don't need to log the time in your application, you can do it with Fiddler.

Upvotes: 2

Related Questions