Output cache does not work with postback on usercontrol
我有一个页面,其中有4个用户控件。其中1个用于过滤另一个控件的内容。我在该控件中有复选框,如按性别过滤,按大小和颜色过滤等....
我在页面上添加了以下代码以进行缓存。当您像选择性别复选框一样对其进行过滤时,它似乎可以工作2-3次,并且它可以工作,如果选择大小过滤器,则它可以工作,但是如果您选择性别过滤器,则它再次不起作用,并且其他控件没有显示结果消息。当我知道有结果时,因为它第一次起作用。
我正在每个过滤器上添加一个查询字符串参数,以便我可以取回结果。
1 | <%@ OutputCache Duration="300" VaryByParam="*" %> |
请求参数
1 | http://somwsite.com/jacktes/?n=0&lp=&hp=&size=&colour=&g=MENS |
我没有运气就尝试了以下方法。
1 2 3 | <%@ OutputCache Duration="300" VaryByParam="none" VaryByControl="GenderFilter" %> <%@ OutputCache Duration="300" VaryByControl="GenderFilter" %> // ID of the checkbox List <%@ OutputCache Duration="300" VaryByParam="n;lp;hp;size;colour" %> // ID of the querystring param |
有人可以帮我吗?
1 | Note: No error message as page works fine BUT out of 4 control the control which shows the filter results is displaying no results. |
在试图找到更好的解决方案时偶然发现了
所以基本上有一个解决方法:
OutputCache返回带有PostBack
的无效版本