这样缓存出现一个问题,是第一次访问哪个,以后显示的全是这个
例如先访问http://127.0.0.1/page.aspx?Mode=01     显示为01.ascx
再访问http://127.0.0.1/page.aspx?Mode=02      时,还是显示01.ascx的内容
为什么?

解决方案 »

  1.   

    <%@ OutputCache Duration="36000" VaryByParam="Mode" %>
    这句应该是写在page.aspx里而不是ascx里吧?
    建议你这么做,在01.ascx和02.ascx里写缓存的语句,03.ascx和page.aspx里不要写不就可以了吗?
      

  2.   

    你的这个问题可能只能通过ihttphandler 来分析http请求来动态载入a.ascx控件,最近在研究这个,不过一直没进展,你可以参考下msdn的 ihttphander接口,IHttpHandlerFactory 和 s
      

  3.   

    在page_load中添加:System.Web.HttpContext.Current.Response.Expires=0;
    System.Web.HttpContext.Current.Response.Buffer=false;试试
      

  4.   

    http://www.microsoft.com/china/community/Column/77.mspx
      

  5.   

    建议你这么做,在01.ascx和02.ascx里写缓存的语句,03.ascx和page.aspx里不要写不就可以了吗?这样不行!System.Web.HttpContext.Current.Response.Expires=0;
    System.Web.HttpContext.Current.Response.Buffer=false;
    这是什么意思?
      

  6.   

    不会吧!我做了一个测试工程没有你说的问题呀!if(this.Request["mode"] != null)
    if(this.Request["mode"].ToString() == "1"){
    Control controlA = this.LoadControl("a.ascx");
    this.Page.Controls[1].Controls.Add(controlA);
    }
    else if(this.Request["mode"].ToString() == "2"){
    Control controlB = this.LoadControl("b.ascx");
    this.Page.Controls[1].Controls.Add(controlB);
    }
    else if(this.Request["mode"].ToString() == "3"){
    Control controlC = this.LoadControl("c.ascx");
    this.Page.Controls[1].Controls.Add(controlC);
    }
    这是加载用户控件的代码。
    其中a.ascx和c.ascx做了缓存b.ascx没有缓存!我运行没有你说的问题呀!我在页面设置缓存标记:<%@ OutputCache Duration = "3600" VaryByParam = "mode" %>
    a和b也是同样的标记!
      

  7.   

    <%@ OutputCache Duration = "3600" VaryByParam = "mode" %>
    放在a.ascx中?
      

  8.   

    应该是:<%@ OutputCache Duration = "3600" VaryByParam = "none" %>吧