WebApplication.SendFile question - Printable Version +- Atozed Forums (https://www.atozed.com/forums) +-- Forum: Atozed Software Products (https://www.atozed.com/forums/forum-1.html) +--- Forum: IntraWeb (https://www.atozed.com/forums/forum-3.html) +---- Forum: English (https://www.atozed.com/forums/forum-16.html) +----- Forum: IntraWeb General Discussion (https://www.atozed.com/forums/forum-4.html) +----- Thread: WebApplication.SendFile question (/thread-1162.html) |
WebApplication.SendFile question - Toni Santa - 07-31-2019 Hi, putting the code in a buttons AsyncClick-event the 4 parameter with the filename is ignored. This can be reproduced with the DownloadFromCache sample project. Code: procedure TIWForm23.btnDownloadAsyncClick(Sender: TObject; In mine real time app I've code where after a SendFile in the browser appears the hourglass and hangs when the same code is executed from the click-event, but works fine from the AsyncClick-event. But the AsyncClick has above problem ignoring the filename. IW15.1.0 Evaluation, Delphi Rio 10.3.1 Thx Toni RE: WebApplication.SendFile question - Alexandre Machado - 08-01-2019 The hour glass is because your IWForm has property LockOnSubmit = True. Set it to false and it will work. RE: WebApplication.SendFile question - matija - 08-05-2019 (08-01-2019, 09:08 AM)Alexandre Machado Wrote: The hour glass is because your IWForm has property LockOnSubmit = True. Set it to false and it will work. This AsyncClick Button-> WebApplication.SendFile('C:\temp\test.pdf', true, '', ''); work in Chrome. Not work IE11? RE: WebApplication.SendFile question - Alexandre Machado - 08-18-2019 SendFile works in all browsers. It is probably being blocked by a popup blocker, no? SendFile() during Async calls is not good idea, IMO. First: it doesn't make any difference in terms of page loading times, flicker, etc. Actually the sync event is more straightforward than the Async event. Second: the browser "understands" a OnClick event which opens a popup window as a direct action of the user, so almost everything is allowed (including opening a popup window). On the other hand, an async event is not a direct user action: the Async event generates a XMLHttpRequest (Ajax) to the server, which responds with JavaScript which then tries to open a popup window. This is - in general - forbidden by browsers, by default, which causes it to fail. So, in short: - OnClick = Sync = direct user action -> browser allows it to open popups - OnAsyncClic = Async/Ajax = user action triggers JavaScript code -> browser doesn't allow it to open popups |