Notes on Values Transmitted by urlreferrer

Source: Internet
Author: User

Request. urlreferrer can obtain information about the URL of the client's last request.
In this way, we can return to the "Previous Page" through this attribute. The example is as follows:

1. Obtain and store the information in page_load.

Page_load (Object OBJ, eventargs E)
{
If (! Ispostback)
{
If (request. urlreferrer! = NULL )//
{
Viewstate ["urlreferrer"] = request. urlreferrer. tostring ();
}
}
}

After the page is sent back, the request. urlreferrer will be changed and directed to the current page. Therefore, you need to make a judgment that this information is only stored on the first request page.

Because the previous URL may not exist, you need to make a judgment and store it only when request. urlreferrer exists.

 

2. Use this information in the return function.

Void return ()

{

If (viewstate ["urlreferrer"]! = NULL)

Response. Redirect (viewstate ["urlreferrer"]. tostring ();

}

when using request. note the following when urlreferrer:
1. if the document. the location method is used to navigate to the current page, request. urlreferrer returns a null value
2. if there are two pages a and B, directly request page A in the browser, and navigate to page B in the page_load event of page A, then request. urlreferrer returns NULL. Because the page has not been initialized in the page_load event, you cannot record the information of the current page. If you navigate to page B, you cannot obtain the information on the previous page.
3. clicking the refresh button does not change the request. urlreferrer

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.