You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

ASPX页面基于条件设置图片URL的部署异常问题咨询

问题:ASPX页面图片加载逻辑服务器端延迟生效

本地运行完全正常,但部署到服务器后,即便IsEnabled值设为true,仍会加载isfalse.gif,数天后才会根据IsEnabled值加载正确图片。

相关代码

后台IsEnabled属性

protected bool IsEnabled 
{
    get { return Utility.GetValue("TestKey"); }
}

Utility类伪代码

public static class Utility
{
    public static bool GetValue(string keyName)
    {
        bool kvalue = false;
        // string value = string.Empty;

        //以下缓存为全局级,下方仅为数据存在形式的伪代码
        Dictionary<string, string> dicCacheDictionary = new Dictionary<string, string>();
        if (dicCacheDictionary.TryGetValue(keyName, out string value))
        {
            if (bool.TryParse(value, out bool result))
                return result;

        }
        else
        {
            //从数据库获取并添加到缓存
            //当前仅为伪代码,硬编码值
            dicCacheDictionary.Add(keyName, "true");
        }
        //若缓存中无数据则从数据库获取
        return kvalue;

    }
}

ASPX页面代码

<asp:Image ID="imgWebcast" ImageUrl='<%#(IsEnabled) ? "../../images/istrue.gif" : "../../images/isfalse.gif" %>'  />

已排查事项

  • 部署前已删除预编译文件缓存
  • 已清除缓存
  • 已重置IIS

我可通过后台代码设置轻松解决该问题,但想确认上述实现方式是否有效,是否存在错误,能否通过该方式实现需求。

内容的提问来源于stack exchange,提问作者Malcolm

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.16 20:21:10