WebFile.ShowURL and 404

Hey all,

I’m sure this is something silly on my end.
I’m generating database files that I use within the web app.
I allow them to be closed and need to have them downloaded.
Really they are just files.

I create a new WebFile, reference it in an array that persists outside the current function, and call ShowURL.
I get the error below in the browser.

I thought initially it was because the file was stored in a path that was not accessible to a web client, so I copied it local to the exe first before trying to prepare the download. Still no go.

Any insight?

Thanks in advance


404: File Not Found

The requested URL “<i hid this because it’s sensitive info>” could not be found. Please check your request and try again.

are you really sure you keep the webfile alive?

[quote=130674:@Chris Halford]I create a new WebFile, reference it in an array that persists outside the current function, and call ShowURL.
I get the error below in the browser.[/quote]

If you simply save the URL, when your function closes, the webfile goes out of scope and the URL is no longer valid. You should use a webfile that is a property of the webpage or the session, so it does not go out of scope prematurely.

It is always better to use the webfile itself than to store the URL anyway. Or use an array of webfiles property instead of a text array.

Make sure to store the WebFile in a place that won’t go out of scope.

I had first tried with the web file local to the function, and it was failing for all the reasons you are describing.
Then I put it in a variable array of files to download, that I declared in the app class. It wasn’t working ONLY because I had a bug that I didn’t detect.

All working now. You guys were right on the money. Thanks.

I’m uncomfortable with this array of files sitting there in the app class. I need to find a way to be sure it’s safe to purge them.

You could attach them to the WebPage. That way, when the page gets closed, they’ll go with it.

Greg,

That’s an excellent suggestion. Implemented and verified.
Thanks.

[quote=130817:@Chris Halford]Greg,

That’s an excellent suggestion. Implemented and verified.
Thanks.[/quote]

Just what I suggested in the third post :wink:

So you did Michel. Sorry I missed that. I was reading the responses on my iPhone at red lights… never the best chances comprehension!

The responses are all appreciated. Especially how quickly they came in. Thank you all.