MichaelD
MichaelD

Reputation: 8767

How to store temporary data from one request to the other in MVC

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.

Upvotes: 1

Views: 2577

Answers (3)

dariol
dariol

Reputation: 1979

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.

Upvotes: 0

Robert
Robert

Reputation: 1466

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.

Upvotes: 0

Andy Rose
Andy Rose

Reputation: 16984

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.

Upvotes: 1

Related Questions