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

Application Caching and ASHX

I am trying to cache some data and pass it to an ASHX handler page to print some barcodes with a 3rd party tool.

I am able to create the cache in my aspx page and pass the data to it, but when I try to retrieve it in the ashx page, I get a "Reference to a non-shared member requires an object reference.

Here is my code in the aspx
            Cache.Insert("DataGridCache", DS, Nothing, DateTime.Now.AddMinutes(10), TimeSpan.Zero)

and my code in the ashx
        Dim DataGridCache As DataSet = CType(Cache.Get("DataGridCache"), DataSet)
  • 2
2 Solutions
Kamal KhaleefaInformation Security SpecialistCommented:
try something like this
HttpCookie cookName = new HttpCookie("Name");
cookName.Value = "Pandian";


string name = Request.Cookies["Name"].Value;
red_75116Author Commented:
using VB,net, but I dont think that matters if I convert above to vb.

If I use this I get an 401 error.  The aplication is windows auth, but the handler needed to be anonyomous so I was able to make that change.

however, any attempt to pass a parameter fails.
Try changing

Dim DataGridCache As DataSet = CType(Cache.Get("DataGridCache"), DataSet)


Dim DataGridCache As DataSet = CType(HTTPContext.Current.Cache.Get("DataGridCache"), DataSet)
red_75116Author Commented:
both of these seemed to work.  thanks
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

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