Questions about 3.1 web, ConfirmMessage and filedownload

Hi guys,
after a while away I am using the current version and have found the stand alone app to be smoother and a bit faster than 2014r2.1 version.

This came up straight away

when you download a file from the site I do this - if there is a better way please say so.

In the MOUSEDOWN event of the download button I put this
Session.ConfirmMessage =""
This is so the user doesn’t get a warning message about leaving the page when they file is being sent to them

the action event creates the file for the download and it is downloaded.
Part of creating the file may or may not involve calls to methods held in session as well.
I.e. a=session.calc(“12*6+1”)

at the end it fires the FileDownloaded method
textfile.ondownloaded = WeakAddressOf FileDownloaded

In the file downloaded method we set the ConfirmMessage back to what we want.

session.ConfirmMessage =“Hi “+session.user.field(“lFullName”).stringValue+” could you please use the Log Out button to close the cloud rather than closing the window.”

The problem I find is that SESSION is sometimes now NIL.
This crashes the app and the file doesn’t download.

I did try the old DIM ses as session = session however this also returns ses=NIL

If I put
IF SESSION <>NIL THEN session.ConfirmMessage ="Hi “+session.user.field(“lFullName”).stringValue+” co…
it works fine however if the users closes the window they don’t get the warning message.

Any ideas how it should be done?

Thanks
Damon

How long does the download take?

The only thing I can think of is that the user is getting disconnected before the download completes and the session dies off. Have you tried using AddressOf instead of WeakAddressOf and then call RemoveHandler when the event fires?

Hi Greg,

maybe 15 seconds to create the file and then 30-40 seconds to download.
Really not that long.

Can you give me an example of how to use the RemoveHandler?

The method is called FileDownloaded however I am not sure what we are removing?

Thanks
Damon

Ok, instead of using OnDownloaded, try redirecting the Downloaded event:

AddHandler TextFile.Downloaded, AddressOf FileDownloaded

Then on the first line of that method you’ll do this:

RemoveHandler File.Downloaded, AddressOf FileDownloaded

will give it a try - thanks