asp.net page jump implementation code
- 2020-05-09 18:28:27
- OfStack
Request.UrlReferrer
Note: if the previous 1 page navigates to the current page using the document.location method, Request.UrlReferrer returns a null value
If there are two pages of A and B, directly request the A page in the browser, navigate to the B page in the Page_Load event in the A page,
Request.UrlReferrer returns empty. Because the page is not initialized in the Page_load event, the information of the current page cannot be recorded,
Navigate to the b page and you won't get the information from page 1
Note: if the previous 1 page navigates to the current page using the document.location method, Request.UrlReferrer returns a null value
If there are two pages of A and B, directly request the A page in the browser, navigate to the B page in the Page_Load event in the A page,
Request.UrlReferrer returns empty. Because the page is not initialized in the Page_load event, the information of the current page cannot be recorded,
Navigate to the b page and you won't get the information from page 1
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
if (Request.UrlReferrer != null)
{
ViewState["UrlReferrer"] = Request.UrlReferrer.ToString();
}
if (Session["user"] != null)
{
if (Request.UrlReferrer != null)
{
Response.Redirect(Request.UrlReferrer.ToString());
}
else
{
Response.Redirect("/");
}
}
username.Value = Request.Form["Uname"];
pass.Attributes.Add("value", Request.Form["password"]);
}
}
/// <summary>
/// Individual member login
/// </summary>
protected void userLog()
{
Lovetrip.BLL.Manage.Users bllu = new Lovetrip.BLL.Manage.Users();
Lovetrip.Model.Manage.Users modeu = bllu.Login(username.Value.Trim(), pass.Text.Trim());
if (modeu != null)
{
Session["user"] = modeu;
Session["userType"] = 1;
Command.Public.MoveUserSession(1);
bbsLogin(modeu.unick);
if (Request.UrlReferrer != null)
{
Response.Redirect(ViewState["UrlReferrer"].ToString());
}
else
{
Response.Redirect("/");
}
}
else
{
Page.ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert(' Incorrect account or password! ')", true);
}
}