Web用户控件ascx的缓存依赖关系 [英] Cache Dependency for web user control ascx

查看:62
本文介绍了Web用户控件ascx的缓存依赖关系的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在网络用户控件中有一个新闻自动收录器,其中包含来自不同网址的新闻,网址由用户控件中名为Feed的公共属性传递给用户控件。我在母版页中使用此用户控件,我不希望在请求内容页面时刷新它。所以,我想到了缓存,我尝试了但是,在我的master.cs的页面加载中,我调用此用户控件,并将一些url设置为User Control的Feed属性,引发异常,空引用,

我试过了httpresponse.clearcacheitem(路径),但是控件仍为null,我才知道,缓存中的控件将为null,



但是,我的要求是根据属性刷新缓存,如果'Feed'属性中的URL(WWW)发生更改,缓存应该刷新,如果没有,缓存版本必须与加载页面有很多延迟。





任何建议都表示赞赏。



我不能使用文件依赖,

I have a news ticker in web user control with news from different urls, the urls are passed to user control by a public property named Feed in the user control. I am using this user control in master page, I don''t want it to be refreshed when ever content page is requested. So, I thought of caching, I tried it but, in the page load of my master.cs where I call this user control with some urls set to the Feed Property of the User Control, an exception is raised, the null reference,
I tried httpresponse.clearcacheitem(path), but still the control is null, I came to know that, the controls in the cache would be null,

But, my requirement is to refresh the cache based on the property , if the urls(WWW) in the ''Feed'' property changes the cache should get refreshed, if not,the cached version has to be used with much delay in loading the page.


any suggestion is appreciated.

I can''t use file dependency,

推荐答案

您正在寻找输出缓存。在这里阅读更多相关信息 - @ OutputCache [ ^ ]。



在您的情况下,您必须将 VaryByParam 属性设置为Feed。



阅读有关该主题的更多信息,然后尝试在您的应用程序中实现它。
You are looking for output caching. Read more about it here - @ OutputCache[^].

In your case, you will have to set VaryByParam attribute to Feed.

Read more about the topic and then try implementing it in your application.


这篇关于Web用户控件ascx的缓存依赖关系的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆