【发布时间】:2013-12-25 17:57:41
【问题描述】:
我在 ASP.NET webcontrols 中使用以下内容:
<%@ OutputCache Duration="86400" VaryByParam="none" %>
这意味着如果控件已经添加到缓存中,则重新加载时控件将为空。问题是在某些页面上我想隐藏这个控件,如果这可以从 MasterPage 代码隐藏文件(加载它的位置)中完成,那就太好了。
我已经试过了:
if (Request.AppRelativeCurrentExecutionFilePath.ToLower().EndsWith("/sites/MySite/default.aspx") || Request.AppRelativeCurrentExecutionFilePath.ToLower().EndsWith("MySite.net"))
{
if(topGames_Mini1 != null)
{
//Load control
topGames_Mini1.visible=true;
}
}
else
{
Page.LoadControl("topGames_Mini1").Visible = false;
}
但是它会在 else 中抛出以下异常:
文件“/Bradspel/sites/MySite/community/topGames_Mini1”没有 存在。
【问题讨论】:
标签: asp.net caching webforms outputcache web-controls