Solved

Adding a Collection to the Cache, asp.net, C#

Posted on 2013-11-07
5
344 Views
Last Modified: 2013-11-07
I was wondering how i could add or insert items into a cache considering multiple ajax posts in a file upload.

This does not work:

((List<RebateImage>)Cache[SessionID]).Add(new RebateImage { Imagetype = imagetype, Filename = fileName, Imagefile = imagetoupload });

It works this way with a session (I can't use session due to a cms), but I am looking for this same concept if I assign a List<RebateImage> to a cache Object.
0
Comment
Question by:crosstf
  • 3
  • 2
5 Comments
 
LVL 75

Expert Comment

by:käµfm³d 👽
ID: 39630477
Can you clarify what you mean by "does not work?"
0
 

Author Comment

by:crosstf
ID: 39631158
It doesn't seem to be adding the item to the collection. Should this syntax work?
0
 

Author Comment

by:crosstf
ID: 39631163
I suppose I should use insert correct? I am using an ajax file upload to post images and add them to a list<t> of the class that I created. I cannot use session, so I thought I would use cache and make the cache ID the sessionID so it would be unique. I need to be able to maintain the collection until a submit button is pressed for a from on another method.
0
 
LVL 75

Accepted Solution

by:
käµfm³d   👽 earned 500 total points
ID: 39631192
I created a new project, and your syntax worked fine for me. Have you stepped through your code to confirm that the cache isn't being dumped (for some odd reason)?
0
 

Author Comment

by:crosstf
ID: 39631298
You are correct, I did do it correctly, for some reason it wouldn't register the record count on the stepthrough..

Thanks!
0

Featured Post

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
In a recent question (https://www.experts-exchange.com/questions/28997919/Pagination-in-Adobe-Acrobat.html) here at Experts Exchange, a member asked how to add page numbers to a PDF file using Adobe Acrobat XI Pro. This short video Micro Tutorial sh…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question