It's mainly the use of request.urlreferrer.
Note: If the previous page uses the Document.location method to navigate to the current page, Request.urlreferrer returns a null value
If you have a,b two pages, request a page directly in the browser, and navigate to page B in the Page_Load event in page A,
The Request.urlreferrer returns empty. Because the page has not been initialized in the Page_Load event, the information for the current page cannot be logged.
Navigate to Page B and you won't get the information from the previous page.
Copy Code code as follows:
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 (' account number or password entered incorrectly!") ') ', true);
}
}