views:

188

answers:

3

In some requests, external data has to be fetched from Soap service. Obviously I don't want to get that data at each call for the same user.

What is the best practice to store temporary data from one request to the other? The data could take up to 10 meg.

+1  A: 

If you really need to persist that amount of data between web requests and the data is specific to the user I would suggest serialising it and storing it a temporary table in a database with a key to the users session. If you are using Sql server session then you can do this via the Session object otherwise you will need to write a custom implementation of this.

If the data is not unique to the user but could be shared then you could store and retrieve it from the appication cache.

Andy Rose
Storing session state in SQL Server seems easiest option. This link should help http://support.microsoft.com/kb/317604
Dan Diplo
10 meg is to big for session state, at least sessions are not ment to be used like that.
Robert
@Robert - that is why I specified using 'Sql server' session state and not 'inproc' session state!
Andy Rose
A: 

A concrete answer depends on more information about the application and about the data structure. You could consider to put the data into a temporary file. If memory is not concern and you don't have lot of parallel users you could use session state.

Robert
Or if you are holding your session state in sql server rather than in memory you could use that rather than writing a custom process to write and retrieve the data. I would suggest saving it to a temp table rather than writing to the filesystem.
Andy Rose
A: 

Maybe storing it in file on disc will be enough but then you must create own implementation of file manager or something like this.

10Mb for session is too big but sending it to the database is waste of resources. Saving to file will be lightest and fastest method for temporary data.

dario-g
The advantage of using Sql Session state is that all the methods are already there for you to save, retrieve and clear the data. If you store to the file system you will need to write these yourself and be very careful with disk space (100 users == 1Gb). You will need to ensure that these files are removed when not needed anymore. I don't really see an advantage in doing this yourself. Ultimately it would be best to try and avoid the need to save this amount of data between web requests.
Andy Rose
"(100 users == 1Gb)" - the same for database. Writing file manager which handle that scenario is not a problem.
dario-g