Link to home
Start Free TrialLog in
Avatar of crosstf
crosstfFlag for United States of America

asked on

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

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.
Avatar of kaufmed
kaufmed
Flag of United States of America image

Can you clarify what you mean by "does not work?"
Avatar of crosstf

ASKER

It doesn't seem to be adding the item to the collection. Should this syntax work?
Avatar of crosstf

ASKER

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.
ASKER CERTIFIED SOLUTION
Avatar of kaufmed
kaufmed
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of crosstf

ASKER

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

Thanks!