PDA

View Full Version : [CLOSED] Reponse Type on a direct method



CanopiusApplications
Aug 25, 2017, 8:54 PM
Hi

I am trying to return a byte array from server side code to jscript via a direct method and cant get it working. Is this the correct syntax? The below succeeds but returns a string as opposed to the byte array.




App.direct.MyMethod(p1, {
responseType: 'arraybuffer',
xhr2: true,
success: function (result) {

[DirectMethod]
public byte[] MyMethod(p1)
{

CanopiusApplications
Aug 28, 2017, 12:42 PM
You can close this as it can't be an Ext problem as I created a c# handler and called it directly from an xmlhttprequest and nothing is returned.

Solutions I found for my problem were

1. Convert the base64 string on the client (direct method) or
2. Just write the entire stream from the handler to the reponse and using an object tag or iframe to display the content

fabricio.murta
Aug 28, 2017, 9:29 PM
Hello @CanopiusApplications!

Thanks for the proactive feedback! And this makes sense. Best I can think using Ext.NET would what you said. Encapsulating the binary data (base64 or MIME are good ways), and return them as string, then working with that on the callback.

Other than that, it could involve actually making it act as a download and write the data to the "download" stream then working with that. Which involves making Ext.NET not handle the response at all.

CanopiusApplications
Aug 29, 2017, 8:50 AM
Hi Fabricio

Yeah ultimately what I did was simply write everything to the stream and work with that. I got the base64 conversion, then blob & then createObjectURL working however I thought it must be slower this way given the conversions and pretty sure I read somewhere there are size limits with the base64 string.

A related thread here : https://forums.ext.net/showthread.php?62083-CLOSED-TabPanel-and-Iframe

Thanks for responding,
D