Only count a download once it's served
See the question and my original answer on StackOverflowYou can try to add this before writing the file:
context.Response.BufferOutput = false;
You can try to add this before writing the file:
context.Response.BufferOutput = false;