I need to stream DocIO to the client as an attachment. Was trying to use this method:
doc.Save("certificate.doc", FormatType.Doc, HttpContext.Current.Response, HttpContentDisposition.Attachment)
but it causes an aborted thread error because it's being called from within an update panel.
Now trying to use the other overload and save to memorystream instead and the good 'ol Response.BinaryWrite(bytes) a byte array method, but it's not working. Below is what I have, but it isn't working, although I have used this method in the past with other products with no problems. Any help would be greatly appreciated.
Dim Certificates As New System.IO.MemoryStream
doc.MailMerge.ExecuteNestedGroup(_ds, _commands)
doc.Save(Certificates, FormatType.Doc)
Dim bytes = New Byte(CType(Certificates.Length, Integer)) {}
Certificates.Read(bytes, 0, CInt(Certificates.Length))
HttpContext.Current.Response.Buffer = True
HttpContext.Current.Response.Charset = ""
HttpContext.Current.Response.Cache.SetCacheability(HttpCacheability.NoCache)
HttpContext.Current.Response.ContentType = "application/ms-word"
HttpContext.Current.Response.AddHeader("content-disposition", "attachment;filenname=certificates.doc")
HttpContext.Current.Response.BinaryWrite(bytes)
HttpContext.Current.Response.Flush()
HttpContext.Current.Response.End()