asp.net uses session to complete: from which page to enter the login page, and return to that page if the login is successful

1. Add in the Load of the Login.aspx page

if (!IsPostBack && Request.UrlReferrer != null)
{
      Session[ "url"] = Request.UrlReferrer;
}

 

2. Add in the login button event

if (Session["url"] != null)
{
     Response.Redirect(System.Web.HttpUtility.UrlDecode(Session["url"].ToString()));//Redirect to the pre-login page
}

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325156307&siteId=291194637