1024programmer Java history.go(-2) is different from the results I want, please give me some advice!

history.go(-2) is different from the results I want, please give me some advice!

UserControls_HeaderMenu (user-defined control, the following is the code to display the user login status)

if (Session[“user_id”] != null)

{

User user = new User();

user.LoadData(Convert.ToInt32(Session[“user_id”]));

LabelHello.Text = “Hello,” + user.LoginName + ““;

LinkButtonLogin.Text = “Leave”;

}

else

LinkButtonLogin.Text = “Login”;

A piece of code for the user login interface:

if (user.Exist) //If the user exists

{

if (user.Password == password) //If password, go to the message list page

                         

If (Request.QueryString[“in”] == null) //Not jumping from within the system

                                              

              Response.Redirect(“BookList.aspx”);

                              

else//It jumps from within the system

                                                   

             
Response.Write(“”);

                                          

}

If you are not logged in, first enter the book browsing interface, and then click Login to enter the login interface. I hope to jump back to the book browsing interface after logging in, but after using history.go(-2) to jump back, the logged in status cannot be displayed. Login . Please give me some advice, thank you! ! !

8 solutions

#1




It must not be displayed. History.go(-2); displays your operations 2 times ago from the COOKIE, and it will definitely not be displayed after login. . .

#2


history.back() means going back to the last history page.

history.go(-1) indicates the first page of recent history

history.go(-2) represents the second page of recent history

#3


Give Lou The main piece of code will enable you to jump after logging in. .

This is usually done

If you judge that you are not logged in on the error.aspx page, you will

Response.Redirect( “http://www.sina.com.cn?returnUrl=http://www.sina.com.cn/error.aspx “);

After someone logs in, you can judge whether there is a returnurl and if so, return to this page and it will be OK.

#4


history.go(-2) In fact, it is the same as clicking the back button of your browser. You can try to see if it refreshes when you click it.

You must send a request to the server again to refresh the login status.

#5


Quoting the reply from wangoqoq on the 3rd floor:

Give the author a piece of code so that you can jump after logging in. .

This is usually done

If you judge that you are not logged in on the error.aspx page, you can

Response.Redirect( “http://www.sina.com.cn?returnUrl=http://www.sina.com.cn/error.aspx “);

After someone logs in, you can judge whether there is a returnurl and if so, return to this page and it will be OK.

This retuHow should rnurl be obtained? It is uncertain which page the user enters first. How to determine which page he entered before logging in?

What is the difference between history.back() and history.go(-1)?

#6


Javascript:The difference between history.go() and History.back()

http://yefei.javaeye.com/blog/333368

#7


request.QueryString[“url”] value

Response.Redirect(request.QueryString[“url”]);

#8


Quoting the reply from ysd_xwl on the 5th floor:

Quoting the reply from wangoqoq on the 3rd floor:

Give the poster a piece of code so that you can jump after logging in. .

This is usually done

If you judge that you are not logged in on the error.aspx page, you can

Response.Redirect( “http://www.sina.com.cn?returnUrl=http://www.sina.com.cn/error.aspx “);

After someone logs in, you will judge whether there is a returnurl…

Get to landing page Just the URL will do. . . . . . Landlord. . . . .

Remember the URL of the requested page and pass it to the login page as a parameter. When the login is successful, jump to the obtained URL.

string url=HttpContext.Current.Request.Url.ToString();

This article is from the internet and does not represent1024programmerPosition, please indicate the source when reprinting:https://www.1024programmer.com/history-go-2-is-different-from-the-results-i-want-please-give-me-some-advice/

author: admin

Previous article
Next article

Leave a Reply

Your email address will not be published. Required fields are marked *

Contact Us

Contact us

181-3619-1160

Online consultation: QQ交谈

E-mail: 34331943@QQ.com

Working hours: Monday to Friday, 9:00-17:30, holidays off

Follow wechat
Scan wechat and follow us

Scan wechat and follow us

Follow Weibo
Back to top
首页
微信
电话
搜索