Asp.net站点地图节点导航不会导致回发

本文关键字:导航 net 站点 地图 节点 Asp | 更新日期: 2023-09-27 17:58:49

工作原理

我有两个页面PageA.aspx和PageB.aspx,还有一个dashboard.aspx。从仪表板,我们可以访问PageA和PageB。当从这些页面导航回仪表板时,我们使用站点地图节点。

PageA站点地图是"Dashboard">"PageA",对于PageB则是"Dashboard>PageB"。我点击Dashboard导航到Dashboard.aspx

条件

在PageA.aspx中,我有一个单选按钮(x和y)和一个提交按钮。我的条件是,当我选择y单选按钮并单击提交时,我应该重定向到PageB.aspx,并且PageB.aspx中的站点地图节点应该重命名为"Dashboard>ConditionX"。但是,如果我直接从dashboard.aspx导航到PageB.aspx,则站点地图节点应为"dashboard>PageB"。

到目前为止我做了什么

在PageA.aspx提交点击中,我检查单选按钮选择并设置会话Session["IsCondition"]=true,然后使用Response.Redirect("~/PageB.aspx")导航到PageB.aspx。

在PageB.aspx的Page_Load()中,我检查会话

if (Session["IsCondition"] != null && Convert.ToBoolean(Session["IsCondition"]))
                    {
                       //My code here if condition is satisfied
                        SiteMap.Provider.CurrentNode.ReadOnly = false;
                        SiteMap.CurrentNode.Title = "ConditionX";
                        SiteMap.Provider.CurrentNode.ReadOnly = true;
                    }
                    else
                    {
                        //My code here if I was directly accessing from Dashboard
                        SiteMap.Provider.CurrentNode.ReadOnly = false;
                        SiteMap.CurrentNode.Title = "PageB";
                        SiteMap.Provider.CurrentNode.ReadOnly = true;
                    }

此外,在dashboard.aspx Page_Load()中,我设置了Session["IsCondition"]=null

问题

当我使用PageA.aspx中的提交按钮重定向到PageB.aspx时,PageB.aspx中的条件工作是正确的,并且网站地图显示为"Dashboard>ConditionX"。从这个页面,如果我点击站点地图中的Dashboard节点,即使我被导航到Dashboard,Dashboard.aspx页面的Page_Load也不会被触发。由于Session值没有从Dashboard页面中清除,单击PageB.aspx将加载PageB,条件不是我想要的

问题

为什么仪表板没有被解雇?我做错了什么?仪表板页面是否正在缓存和显示,而page_load没有被触发?

Asp.net站点地图节点导航不会导致回发

Response.Cache.SetNoStore()在主页Page_Load()中解决了

问题