[CLOSED] Can I use Response object in a direct method call?

  1. #1

    [CLOSED] Can I use Response object in a direct method call?

    Hello I experiment a lot of problem with that.

    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]
  2. #2
    Hi,

    I think you should set up
    isUpload : true
    in a DirectMethod config.

    Example
    App.direct.TestDirectMethod(params, {
        isUpload : true
    });
    Does it help?
  3. #3
    I will try that but if it is like the success I want to implement...

    Look:
            App.direct.BuildPanelByDirectMethod( Title, left, top, ChartName, panWidth, panHeight );
    I have parameters in my direct method call, so how to implement this functionnality?

    Edit :

    I've just try:
    var SaveChartClick = function (chart)
    {
        App.direct.SaveCharts( chart, Ext.draw.engine.SvgExporter.self.generate( null, Ext.getCmp( chart ).surface ), {
            isUpload: true
        } );
    };
    Call works, but answer still the same

    Click image for larger version. 

Name:	dm.png 
Views:	96 
Size:	31.4 KB 
ID:	4355

    Edit 2:

    Oups, very sorry, I misplaced the call in my code (I have a dead function to delete). Placed in good function it works.

    You can close the thread.

Similar Threads

  1. [CLOSED] Output Cache issue with Direct Method / Direct Event
    By amitpareek in forum 1.x Premium Help
    Replies: 18
    Last Post: Mar 01, 2013, 5:03 AM
  2. [CLOSED] Call ajax and wait for response
    By Marcelo in forum 1.x Premium Help
    Replies: 2
    Last Post: Aug 15, 2012, 10:33 AM
  3. Replies: 0
    Last Post: Aug 05, 2012, 10:46 AM
  4. [CLOSED] Uncaught TypeError: Object #<Object> has no method '***'
    By Sevilay Tanış in forum 1.x Premium Help
    Replies: 7
    Last Post: Mar 27, 2012, 4:44 PM
  5. how to call direct method in asp.net mvc3
    By waqasde in forum 2.x Help
    Replies: 1
    Last Post: Mar 16, 2012, 9:26 AM

Posting Permissions