Large file causing problem with Ajax Refresh and/or Download to disk

Large file causing problem with Ajax Refresh and/or Download to disk

We use an ajax refresh to move between different pages (webblocks) on a form (same Web Screen).  The user can upload documents at various stages in the process and I'm finding the action to move is timing out if the user has uploaded a somewhat large document (it definitly hangs if the document is over 5MB).  I also can't download the document.  I don't have a problem when the documents are smaller.  I don't consider 5 MB to be huge, but it definitely seems to be a problem.  They can upload it just fine, but trying to download it (save to Disk) or move to the next page (ajax refresh to get a different webblock) just results in a timeout on screen and a logged error in Service Center.

We are on version 8 of the platform (PaaS).  

Any ideas?
Hi Cory,

After they upload the file what do you do with it?
Upload to database or keep it in a screen variable?

Also what is the error that gets logged?

João Rosado
The upload is done via a popup that stores it to the database.  The preparation of the main webblock checks to see if the document exists and if it does, then it gives the option to download or delete it.  After an upload is done, the OnNotify action refreshes that query and then does an ajax refresh of the container to show the file name with upload/download options.

When I go into the screen after they upload the document, I experience the same problem with it timing out when I try to move to the next screen.

Here is the error:
Error Detail
Time of Log:
10-09-2015 07:48:30
Session Id:
No session
Request timed out.

eSpaceVer: 47 (Id=219, PubId=817, CompiledWith=
RequestUrl: (Method: POST)
AppDomain: /LM/W3SVC/1/ROOT/Applicant-6-130842821211220000
FilePath: d:\OutSystems\Platform Server\running\Applicant.01341204282\
Locale: en-US
DateFormat: dd-MM-yyyy
PID: 3036 ('w3wp', Started='8/17/2015 10:41:58 AM', Priv=1355Mb, Virt=6548Mb)
TID: 3
Thread Name: 
.NET: 2.0.50727.5485

Have you set your upload limits on IIS to allow a file that large?

Where would we do that within the platform?  We are hosted so I don't know if we have that option.  Since it is saving the file just fine (upload is working), why would that make a difference?

Cory -

If you are hosted you can't change it. I misread your original post, I saw the problems downloading but I thought you were *also* having upload timeouts... so you can ignore the upload limit question.

It sounds almost like the DB queries are now taking forever. When you do the query, is there anything on that screen at all making use of the file contents? For example, are you doing something like checking the file size and showing it on the screen? Or checking to see that the file has contents? Etc.?

I ask, because it can be slow to push big binary content from the DB to the app server. The query optimizer will ignore the field with the file content and not pull it over if it sees that you are not doing anything with that field, but if you are, it will also request that field and make your query much slower.

The preparation checks to see if a filename exists to update a session variable, but nothing is done to check file size or anything with the contents (until they try to download the file). The page is slow to load when there is a large document (but it will load), but when moving to the next screen I don't do anything with the file at all, which is why this is so odd to me.  I could be off and it might be something else that is causing the problem, but the only time I am seeing the problem is when we have a large file that has been uploaded.  That combined with the fact that I'm having problems downloading the large file makes me think there is something going on related to the file size.

I can run the query that it does in the Move action (when they navigate to the next page) with no problem.


Correct me if I'm wrong, but from what I understood you:
  • Have a query in the preparation that checks for the file
  • Refresh that query after the upload
  • In the download action you get the binary from the query in the preparation

Is that correct?
if that's what you have, then the problem is that the binary is going to the "viewstate".
The viewstate is the storage of data that you need in subsequent actions in a page. So any information that is on a screen variable or preparation output gets stored there if it's necessary in an action.

The problem is that the viewstate is sent back and forward in all requests, so after you refresh the query it gets a huge amount of data there and breaks the next request.

The solution is easy, never access he binary file in the query on the preparation. Repeat the query inside the download action to get the binary.
That way the platform will be able to optimize the preparation query to never get the binary from database, never put it in the viewstate and make your page faster :)

João Rosado
"never access the binary file in the query on the preparation. Repeat the query inside the download action to get the binary."  

That's a good tip there -

I couldn't get the file to timeout in development, but it would get really slow after I uploaded a large document.  Changed the download action so that it was passed the document identifier and performed the query on that identifier and then would download.  Speeded everything up dramatically.  I've got quite a few changes queued up right now because I'm waiting on copy from the business unit, but I may have to backdoor this change into production and see if it solves the problem - will also probably end up recommending we limit the size of the uploads - really, who needs a 5 meg resume?

Will keep you posted.
I just got the OK and made the change in production - this was exactly my problem.  

THANK YOU - now I just have to go everywhere else that they can download a document and make sure to do the same.