Response.Cache.SetNoStore()
in the master page Page_Load()
solved the problem
Asp.net sitemap node navigation does not cause postback
Pergunta
Working principle
I have two pages PageA.aspx and PageB.aspx and also a dashboard.aspx. From dashboard, we can access PageA and PageB. When navigating back to dashboard from these pages, we use sitemap nodes.
PageA sitemap is 'Dashboard > PageA' and for PageB it is 'Dashboard > PageB'. I click on Dashboard to navigate to dashboard.aspx
Condition
In PageA.aspx I have a radio button (x and y) and a Submit button. My condition is that when I select y radio button and click on submit, I should be redirected to PageB.aspx and the sitemap node in PageB.aspx should be renamed to 'Dashboard > ConditionX'. But if I am navigating directly from dashboard.aspx to PageB.aspx then the site map node should be as 'Dashboard > PageB'.
What I have done so far
In PageA.aspx submit click, I check the radio button selection and set a session Session["IsCondition"]=true
and then use Response.Redirect("~/PageB.aspx")
to navigate to PageB.aspx.
In Page_Load()
of PageB.aspx I check the session
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;
}
Moreover, in dashboard.aspx Page_Load()
I have set Session["IsCondition"]=null
Problem
When I use the submit button from PageA.aspx to redirect to PageB.aspx then the conditional working is correct in PageB.aspx and the sitemap is shown as 'Dashboard > ConditionX'. From this page, if I click on Dashboard node in site map, Page_Load
of dashboard.aspx page is not fired even though I am navigated to Dashboard. Since the Session value is not getting cleared from Dashboard page, clicking on PageB.aspx will load PageB with the condition which is not what I want
Question
Why is the dashboard not getting fired? What am I doing wrong? Is the dashboard page being cached and shown for which the Page_load isn't getting fired?
Solução