Reputation: 9001
I have controller with 2 methods. First method should set variable and do something. Second method (called by ajax) should get value of this variable. So, I can't use TempData and Cache (because there are 2 different requests). How to solve it? Use Session? But session is disabled by default in asp.net mvc and I'm afraid to have unexpected behavior of the whole application if I enable it... Global variables are not approved too (because I need to get value of variable for concrete user)
EDIT: workflow is:
So, in Cancel method I need to know the unique name of file, which is being uploaded. I have to store this name in Upload method in any storage (i.e. Redis, DB etc) and remove from this storage after upload success (or in Cancel method, if Cancel was called)
Upvotes: 0
Views: 1127
Reputation: 1455
Then I would suggest to keep the value in a cookie for that user if the data is not to sensitive.
If the data is sensitive you need to store if for example in the cache of the server. There you keep a record per user and then reuse that and discard it after you have done the processing. This works well when you have one instance of the website. When you don't you should look at for example a redis cache, sql server, azure table storage, ...
Upvotes: 2