G
Guest
Hi,
I have a strange problem with a usercontrol on a page. The usercontrol
dispalyes three categories (From a database) when the user clicks a category
they see all the products in a shop for that category, the results are paged
10 to a page and the user can page them.
As this "Category" usercontrol hardly ever changes I wanted to setup up
caching for it. However I realised that when the user clicks a ctageory it
is selected and therfore I would need to cache each instant of the control
varied by the selected category ID. As the category ID is in the querystring
I used varybyparam. Here is my output cache directive for the usercontrol:
<%@ OutputCache Duration="360" varybyparam="CategoryID" shared="true" %>
There is a problem though. When the user selects a category, the correct
one is dispalyed and is shown as selected. Howevere when they click "next
Page" the wrong cahced version of the usercontrol is displayed.
I have stepped through this. I placed a breakpoint in the page load of the
usercontrol. This is what happens:
(When I click on a category a redirect is performed, to the same page but
changing the CategoryID querystring)
1) First page loads - Usercontrol is loaded from DB. (Breakpoint Hit)
2) I click on Category1 - Usercontrol is loaded from DB. (Breakpoint Hit)
3) I click on Category2 - Usercontrol is loaded from DB. (Breakpoint Hit)
4) I click on Category3 - Usercontrol is loaded from DB. (Breakpoint Hit)
2) I click on Category1 - Usercontrol is loaded from CACHE.
3) I click on Category2 - Usercontrol is loaded from CACHE.
4) I click on Category3 - Usercontrol is loaded from CACHE.
5) I click "Next Page". Postback Occurs. Usercontrol is loaded from CACHE.
Wrong cached instance is used though.
It seems as though after a postback the varybyparam is going awol.
Can anybody Help?
PS The usercontol has viewstate disabled, but enabling it makes no diffrence.
I have a strange problem with a usercontrol on a page. The usercontrol
dispalyes three categories (From a database) when the user clicks a category
they see all the products in a shop for that category, the results are paged
10 to a page and the user can page them.
As this "Category" usercontrol hardly ever changes I wanted to setup up
caching for it. However I realised that when the user clicks a ctageory it
is selected and therfore I would need to cache each instant of the control
varied by the selected category ID. As the category ID is in the querystring
I used varybyparam. Here is my output cache directive for the usercontrol:
<%@ OutputCache Duration="360" varybyparam="CategoryID" shared="true" %>
There is a problem though. When the user selects a category, the correct
one is dispalyed and is shown as selected. Howevere when they click "next
Page" the wrong cahced version of the usercontrol is displayed.
I have stepped through this. I placed a breakpoint in the page load of the
usercontrol. This is what happens:
(When I click on a category a redirect is performed, to the same page but
changing the CategoryID querystring)
1) First page loads - Usercontrol is loaded from DB. (Breakpoint Hit)
2) I click on Category1 - Usercontrol is loaded from DB. (Breakpoint Hit)
3) I click on Category2 - Usercontrol is loaded from DB. (Breakpoint Hit)
4) I click on Category3 - Usercontrol is loaded from DB. (Breakpoint Hit)
2) I click on Category1 - Usercontrol is loaded from CACHE.
3) I click on Category2 - Usercontrol is loaded from CACHE.
4) I click on Category3 - Usercontrol is loaded from CACHE.
5) I click "Next Page". Postback Occurs. Usercontrol is loaded from CACHE.
Wrong cached instance is used though.
It seems as though after a postback the varybyparam is going awol.
Can anybody Help?
PS The usercontol has viewstate disabled, but enabling it makes no diffrence.