I need your help with this strange issue. I am developing the web application where users can download files generated on the fly.

Please, take a look at the code below. Independently of the value of 'sleep' variable, browser (tested on Chrome, Firefox, IE Edge) shows a download in progress when the first 2MB was sent. So, the browser always starts downloads at 2Mb. Do you know, what I can do to show download progress from the first byte sent to the client?

    int sleep = 1000;
    HttpContext.Current.Response.ContentType = "application/zip";
    HttpContext.Current.Response.AppendHeader("Content-Disposition", "attachment; filename=\"temp.zip\"");

    // we don't want to have buffer output because of possible excessive memory usage
    HttpContext.Current.Response.BufferOutput = false;

    int i = 0;
    while (true)
        byte[] oBuffer = new byte[100000];
        HttpContext.Current.Response.OutputStream.Write(oBuffer, 0, 100000);
        if (i>100)


Related posts

Recent Viewed