I am trying to do something that I'm not sure is possible or not?
The user opens the website. If they try to reopen the link in a new tab I need to redirect them to another page.
I've tried using c#
to see if I can detect a page reload. This works, but if I put my code in the page load event for some reason it runs twice, and it redirects them no matter if it's the first time they opened or if they are opening in a new tab. I need to only happen if they open a new tab.
My Code:
bool IsPageRefresh = false;
if (!IsPostBack)
{
ViewState["ViewStateId"] = System.Guid.NewGuid().ToString();
Session["SessionId"] = ViewState["ViewStateId"].ToString();
}
else
{
if (ViewState["ViewStateId"].ToString() != Session["SessionID"].ToString()) ;
{
IsPageRefresh = true;
if (IsPageRefresh == true)
{
Response.Redirect("~/Pages/EstimateList.aspx", true);
}
}
Session["SessionId"] = System.Guid.NewGuid().ToString();
ViewState["ViewStateId"] = Session["SessionId"].ToString();
}
Do I need to use Javascript
or jQuery
to do this? I'm really new to Javascript
and jQuery
.