我正在制作一个应用程序,其中我们可能有 5 或 6 个步骤。在第一步中,我将选择我需要的报告并保存并继续......它会让我进入第二步......就像这样......我的问题是根据功能,当我点击浏览器后退按钮时,我需要去到上一页。当我再次按下它时,它必须转到我的主页,但它会将我重定向到上一页。它适用于除 chrome 和 safari 之外的所有浏览器。我正在插入我的代码以供参考..请帮我解决这个问题..
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");
}
}