I have a site on asp.net and I need to store quite large files, 2-4 files each up to 10 MB between postbacks. Now I store them in sessions, but the admin asked to find a solution that is less demanding on the amount of RAM on the server.

  • What are the disadvantages of storing 40 mb files in Viewstate?

  • Is the viewstate sent in the request with every postback, even if it is not used there?

    1 answer 1

    Viewstate sent with each request and is still encrypted. You cannot store such large files in it. To speed up websites, there is the practice of turning off Viewstate altogether.

    If your files are shared between all users, then replace storage in session with Cache storage.

    You can also use a third-party cache service (memcached, redis, etc.).

    To save RAM, you can store your temporary files on disk between requests. With a small amount of RAM, you will have to make a choice between performance (stored in the memory of any cache service) and memory load (stored on disk).

    If the task allows it, you can try to alter the sequence of working with files eliminating the need for their storage between requests. For example, in the beginning we collect information about the processing of files from the user and only at the end apply all the algorithms to the data from the files.