简体   繁体   中英

Chrome/Safari Back button issue

I am making an application in which we may have 5 or 6 steps. In first step, i will select the report which i need and save&continue..it will get me to second step...like so... my problem is according to functionality, when i hit on the browser back button i need to go to previous page. and again when i press it second time it has to go to my home page , but it is redirecting me to the previous page. It is working in all browsers except in chrome and safari. I am inserting my code for reference..please help me to solve this..

protected void Page_Load(object sender, EventArgs e)
{

    DisableHistory();
    lnkBackBrowse.Style["visibility"] = "hidden";
    if (Session["UserId"] != null)
    {
        if (Convert.ToInt32(Session["UserId"].ToString()) == 0)
        {
            TopNavigationMenu.Style["visibility"] = "hidden";
            NavigationMenu.Style["visibility"] = "hidden";

            if (!Request.Url.ToString().Contains("Home") && !Request.Url.ToString().Contains("SaveandLogout"))
                Response.Redirect("Home.aspx");
        }
        else
        {
            TopNavigationMenu.Items[0].Text = "Welcome :" + Session["UserName"].ToString();
            TopNavigationMenu.Style["visibility"] = "visible";
            NavigationMenu.Style["visibility"] = "visible";

            if (Session["FirstTimeLogged"] != null && Convert.ToBoolean(Session["FirstTimeLogged"]) == true)
            {
                TopNavigationMenu.Enabled = false;
                NavigationMenu.Enabled = false;

                if (!Request.Url.ToString().Contains("MyAccount"))
                    Response.Redirect("Home.aspx");
            }
            else
            {
                GenerateLinks(Session["RoleId"].ToString());
                TopNavigationMenu.Enabled = true;
                NavigationMenu.Enabled = true;
                //TopNavigationMenu.Items[1].Text = "Support <img src='Images/bullet_arrow_down.png' alt='down' title='' />";

                if (Request.Url.ToString().Contains("Home"))
                    Response.Redirect("Default.aspx");

                if (!IsPostBack)
                {
                    string strPrevPg = "", strCurrPg = "";
                    if (Request.UrlReferrer != null)
                    {
                        strPrevPg = Request.UrlReferrer.AbsolutePath.ToString();
                        strPrevPg = strPrevPg.Substring(strPrevPg.IndexOf("/", 1) + 1, strPrevPg.Length - (strPrevPg.IndexOf("/", 1) + 1));
                        strPrevPg += Request.UrlReferrer.Query.ToString();
                    }
                    strCurrPg = Request.Url.AbsolutePath.ToString();
                    strCurrPg = strCurrPg.Substring(strCurrPg.IndexOf("/", 1) + 1, strCurrPg.Length - (strCurrPg.IndexOf("/", 1) + 1));

                    bool bFlag;
                    bFlag = Convert.ToBoolean(Session["goBackPg"]);

                    if (Session["PrevPg"] != null)
                    {
                        if (strCurrPg == Session["PrevPg"].ToString())
                        {
                            if (bFlag)
                            {
                                Session["CurrPg"] = strCurrPg;
                                Session["PrevPg"] = "Default.aspx";
                                bFlag = false;
                                Session["goBackPg"] = bFlag;
                            }
                            else
                            {
                                Session["CurrPg"] = strCurrPg;
                                Session["PrevPg"] = strPrevPg;
                            }
                        }
                        else
                        {
                            Session["CurrPg"] = strCurrPg;
                            Session["PrevPg"] = strPrevPg;
                            bFlag = false;
                            Session["goBackPg"] = bFlag;
                        }
                    }

                }
            }
        }
    }
    else
    {
        Response.Redirect("home.aspx");
    }
}

Those browsers are showing you cached content when you press the back button.

You can debug and check, your server is not being hit. This Session code will not work.

You could tell the browser not to cache the page . That way if the user wanted to go back, he would have to reload the content.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM