Running the code after the Response.TransmitFile action completes
I am using Response.TransmitFile to fetch a file from a web service. I would like to measure the time this process takes from the server's point of view.
I tried to grab the tick counter before and after this call, but that obviously didn't mean how long the transfer had passed. This gave me numbers of 0.0016 milliseconds for a 30MB file. :-)
Any ideas?
source to share
The transfer is asynchronous, as you've seen.
You can get what you want by turning off buffering in HttpResponse ( Response.Buffer = false
) before calling TransmitFile
. If that fails, transfer it "manually" and synchronously using a FileStream .
If you only want to observe the time it takes to transfer, just for your information, and you don't need to log the time in your application, you can do that with Fiddler.
source to share