用了两种方法都不起作用:
方法一:使用轮流查询机制:
<%@ OutputCache Duration="30" VaryByParam="none" SqlDependency="TB:student" %>webconfig:
<caching>
<sqlCacheDependency enabled="true">
<databases>
<add name="TB" connectionStringName="TbString" pollTime="500"/>
</databases>
</sqlCacheDependency>
</caching>方法二:SqlServer 2005通知机制:
<%@ OutputCache Duration="30" VaryByParam="none" SqlDependency="CommandNotification" %>页面后台:
    protected void Page_Load(object sender, EventArgs e)
    {
        SqlDependency.Start(ConfigurationManager.ConnectionStrings["TbString"].ConnectionString);    }但是无论我怎么更改student表,两种方式在30秒内的缓存都不更新,就貌似SqlDependency不起作用,有没有遇到过同样问题的大哥?

解决方案 »

  1.   

    <%@ OutputCache Duration="30" VaryByParam="none" SqlDependency="TB:student" %> Duration="30" 这不是设30秒缓存的吗,,,
      

  2.   


    不加这一句SqlDependency="TB:student"是30秒,但是有了这一句按MSDN说的应该发现student表发生改变后立即更新缓存才对
      

  3.   

    MSDN这样解释的:示例演示如何指示输出缓存按页或用户控件的位置对它们进行缓存,并根据窗体的 POST 方法或查询字符串对窗体参数进行计数。每个收到的具有不同位置或计数参数(或两者)的 HTTP 请求都进行 10 秒的缓存处理。带有相同参数值的任何后继请求都将从缓存中得到满足,直至超过输入的缓存期。<%@ OutputCache Duration="10" VaryByParam="location;count" %>