Jigsaw Blog

20

Nov
2013
0 comments

Browser hangs when programatically streaming PDF to client

The client installed a new internal universal access gateway (UAG) and reports which previously streamed back as PDF to the browser stopped working - the browser seemed to hang waiting for the report to arrive.

The was to add the bold line below. It seemed the UAG was waiting for the end of the stream and once we added the header for Content-length all was good.

                    Response.Clear();
                    Response.ContentType = "application/" + strMimeType;
                    Response.AddHeader("Content-disposition", "attachment;filename=" + strFileName);
                    Response.AddHeader("Content-length", bytes.Length.ToString());
                    Response.OutputStream.Write(bytes, 0, bytes.Length);
                    Response.OutputStream.Flush();
                    Response.OutputStream.Close();
                    Response.Flush();
                    Response.Close();