Solved

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

Posted on 2013-11-07
5
342 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 74

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 74

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

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
This video discusses moving either the default database or any database to a new volume.
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

708 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now