• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 357
  • Last Modified:

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.
0
crosstf
Asked:
crosstf
  • 3
  • 2
1 Solution
 
käµfm³d 👽Commented:
Can you clarify what you mean by "does not work?"
0
 
crosstfAuthor Commented:
It doesn't seem to be adding the item to the collection. Should this syntax work?
0
 
crosstfAuthor Commented:
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
 
käµfm³d 👽Commented:
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
 
crosstfAuthor Commented:
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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now