Streaming Files - No Dialog RRS feed

  • Question

  • User-860009756 posted

    Not sure where to put this question isn't VB specific but doesn't look to fit the other forums?

    I have a system which needs to be secure which streams relatively large documents from a webservice to a proxy (Web site) whch then grabs the stream and pushes this to the client. This works but there are some issues where it seems the response is not being pushed until the entire stream is complete? whether this is the case Im not sure have run charles and until it completes it is "Waiting for response".

    The documents are currently PDF but it needs to handle many other types for the future. The octet stream etc is mostly testing related,

    Any ideas on how to get the Dialog to show - saying save as? for the large files the little ones don't matter to much but the big ones leave a big waiting period with no response.

    		Dim IncomingResponse As HttpWebResponse = DirectCast(Request.GetResponse(), HttpWebResponse)
    			Dim IncomingStream = IncomingResponse.GetResponseStream()
    			Dim BufferSize As Integer = 65536
    			Dim Buffer(BufferSize) As Byte
    			Dim Count = IncomingStream.Read(Buffer, 0, BufferSize)
    			While (Count > 0)
    				Context.Response.OutputStream.Write(Buffer, 0, Count)
    				Count = IncomingStream.Read(Buffer, 0, BufferSize)
    			End While

    			Dim ApplicationType As String = R.DocumentFileType.ToLower
    			If Not ApplicationType.Contains("application/"Then
    				ApplicationType = "application/" & ApplicationType
    			End If
    			Dim AttachmentStr = ""
    			If (R.DocumentSize / 1000)  > 1000 Then '1MB ish
    				AttachmentStr = "attachment; "
    				ApplicationType = "application/octet-stream"
    			End If
    			Response.AddHeader("Content-Type", ApplicationType)
    			Response.AddHeader("Content-Disposition", AttachmentStr & "filename=" & FileName.Replace(" ""_"))

    Tuesday, August 2, 2011 3:53 PM