The following piece of code can be used to write a memory stream to any browser. In my case its a pdf file so i am using “HttpContext.Current.Response.ContentType = “application/pdf” ” only this line is changed when there is amy other type of file in memory stream:
Public Sub ViewMS(ByVal fs As MemoryStream) Dim buffer(fs.Length) As Byte fs.Position = 0 fs.Read(buffer, 0, fs.Length) HttpContext.Current.Response.Buffer = False HttpContext.Current.Response.ContentType = "application/pdf" 'In my case its a pdf HttpContext.Current.Response.OutputStream.Write(fs.GetBuffer(), 0, fs.Length) HttpContext.Current.Response.Flush() HttpContext.Current.Response.End() fs.Dispose() fs.Close() End Sub
Hope this may help anyone


