Last post Sep 23, 2015 08:02 AM by ericallenpaul
Sep 22, 2015 01:46 PM|ericallenpaul|LINK
Is it possible to have the Varybycustom string supplied/created by the page in a Web Forms App?
I have a page with a search filter and I want to create a string in the page like "Color:Red;Size:Lg" and have the cached item be created based on that parameter.
All of the examples I've seen use an existing variable that already exists in HttpContext. Everything I have tried so far doesn't seem to work. A property on the page can be read but the timing is somehow wrong to create anything but the very first cache
entry. I can read a cookie from the GetVaryByCustomString but when I set a cookie on the page I want to cache it seems to remove caching from the page, GetVaryByCustomString never fires.
I don't understand how Varybycustom would be very useful if you can't actually supply a custom string. I can set a string by using Response.Cache.SetVaryByCustom(SomeOutputCacheKey); but that produces weird results. It seems to create unique cache entries
the first couple of times but after a point all of the autopostback stuff seems to quit working. Using varybyparam="*" the first trip produces and entry for the page and an entry for webresource.axd file so I get a total of 4 cache entrys. The second trip
will give me 8 cache entries but the third try will always just return the second entry.
Is what I'm trying to do even possible?
Sep 23, 2015 03:40 AM|Weibo Zhang|LINK
According to the following first article, you could see the how to use the
VaryByCustom Property, as the second link shows, you could have a try to set the VaryByParam equals “” or “none”.
I hope it’s useful to you.
Sep 23, 2015 08:02 AM|ericallenpaul|LINK
Thanks for the info. As soon as I get this all figured out I'll come back and post a solution.
I have opened a case with Microsoft.