06-02-2023, 08:31 AM
Thank you Alexandre.
So I solved with a differente approach: into the async response provided by IW I send a message like "download at this URL" and the client-side JS script execute samething like this:
Server side, I used a cache file URL for browser managed content (i.e. PDF), or a TContentBase descendant custom URL on order to respond with a WebApplication.SendFile(FileName,true) for other files type (i.e. .p7m, client side file download).
But also I have also this older code working:
Client side:
Server side I've registered the "global.infowebDocOpen" on a procedure like this:
And it works even better than my code upper: PDF file is opened in a new browser tab, and for non managed file extension (like a .doc) a download starts.
Since executeAjaxEvent() is also an asynchronous event handling of IntraWeb, I thought it worked similarly in calling ajaxCall() which looks similar and simplifies response handling.
At this point I could use a second approach, in which the use of ajaxCall() is abandoned, instead returning to the previous executeAjaxEvent() which instead supports SendFile, and simplifies the entire call-and-response process for opening or downloading files, without the need to use two steps above.
So I solved with a differente approach: into the async response provided by IW I send a message like "download at this URL" and the client-side JS script execute samething like this:
Code:
var w = window.open();
if(!w || w.closed || typeof w.closed=='undefined') {
toastr("info","File",clkLang(["Controllare eventuali blocchi di popup del browser","Please check if browser locked popup"]));
};
w.location = r.hRef;
w.focus();
Server side, I used a cache file URL for browser managed content (i.e. PDF), or a TContentBase descendant custom URL on order to respond with a WebApplication.SendFile(FileName,true) for other files type (i.e. .p7m, client side file download).
But also I have also this older code working:
Client side:
Code:
executeAjaxEvent(`&mode=${mode}&k=${k}&fn=${fn}&op=open`, null, "global.infowebDocOpen", false, null, false);
Server side I've registered the "global.infowebDocOpen" on a procedure like this:
Code:
... prepare the file ...
WebApplication.SendFile(FileName, false, '', '')
And it works even better than my code upper: PDF file is opened in a new browser tab, and for non managed file extension (like a .doc) a download starts.
Since executeAjaxEvent() is also an asynchronous event handling of IntraWeb, I thought it worked similarly in calling ajaxCall() which looks similar and simplifies response handling.
At this point I could use a second approach, in which the use of ajaxCall() is abandoned, instead returning to the previous executeAjaxEvent() which instead supports SendFile, and simplifies the entire call-and-response process for opening or downloading files, without the need to use two steps above.