Jun 12, 2012, 8:59 AM
[CLOSED] Can I use Response object in a direct method call?
Hello I experiment a lot of problem with that.
Here my direct method :
To not that
I try a lot of solution since this morning and nothing seems to work. So my question.
And the fact is direct method run well, but the return no.
Here my direct method :
<DirectMethod()> Public Sub SaveCharts(ByVal ChartName As String, ByVal chartSVG As String)
Dim ms As New MemoryStream()
SavePNG(ms, chartSVG, ChartName)
'Convert the memorystream to an array of bytes.
Dim byteArray() As Byte = ms.ToArray()
'Clean up the memory stream
ms.Flush()
ms.Close()
' Clear all content output from the buffer stream
Response.Clear()
Response.BufferOutput = True
Response.ClearHeaders()
' Add a HTTP header to the output stream that specifies the default filename
' for the browser's download dialog
Response.AddHeader("Content-Type", "application/force-download")
Response.AddHeader("Content-Disposition", "attachment; filename=" + ChartName + ".jpg")
Response.AddHeader("Content-Length", byteArray.Length.ToString())
' Add a HTTP header to the output stream that contains the
' content length(File Size). This lets the browser know how much data is being transfered
' Set the HTTP MIME type of the output stream
Response.ContentType = "application/octet-stream"
' Write the data out to the client.
Response.BinaryWrite(byteArray)
Response.End()
End Sub
Whatever I try to get the return in the browser, I get a BADRESPONSE erreur with error code 200. so, my method is well executed, but the response is not/bad send.To not that
SavePNG(ms, chartSVG, ChartName)
is well run and produce attende result. If I save the result to disk, I get the image saved.I try a lot of solution since this morning and nothing seems to work. So my question.
And the fact is direct method run well, but the return no.
Last edited by Daniil; Jun 12, 2012 at 2:08 PM.
Reason: [CLOSED]