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.
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.
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.
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.
精彩评论