We try to implement a download.aspx to control our source such as images for specific clients. we use the buffering method in download.aspx.cs. The code is showed below:
using (var fs = new FileStream(_path, FileMode.Open, FileAccess.Read))
{
Response.BufferOutput = false; // to prevent buffering
byte[] buffer = new byte[1024];
int bytesRead = 0;
if (_file.Extension == ".pdf")
{
Response.AddHeader("Content-Disposition", "inline; filename=" + _file.Name);
}
else
{
Response.AddHeader("Content-Disposition", "attachment; filename=" + _file.Name);
}
Response.AddHeader("Content-Length", _file.Length.ToString());
Response.ContentType = ReturnExtension(_file.Extension.ToLower());
while ((bytesRead = fs.Read(buffer, 0, buffer.Length)) > 0)
{
Response.OutputStream.Write(buffer, 0, bytesRead);
}
}
It works well when downloading a single files. However, in our situation, we are try to load about twenty images at the same time. It become extremely slow. The following is the captured screen:-

We can’t find out the reasons. We would like to know it is a practical method to control files or there are the other better way to achieve it.
I agree with the above response. However if this is the route you “have to go”. you could have a look at the following.
You are using a asp.net Page, rather go the Handler route, you cut out a lot of the asp.net life cycle, and this will help reduce your images load time.
Second have a look at Asynchronous HTTP Handler.
You can also look at caching the response output which will help improve the performance.
read this
I hope some of this information helps.