简体   繁体   English

Chrome / Safari后退按钮问题

[英]Chrome/Safari Back button issue

I am making an application in which we may have 5 or 6 steps. 我正在制作一个可能需要5到6个步骤的应用程序。 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. 它适用于所有浏览器(Chrome和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. 这样,如果用户想返回,他将不得不重新加载内容。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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