Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get Previous Page Url

Tags:

c#

asp.net

How to get previous page url?

senario, user might come form google, yahoo, bing.
how to know where they come from?

i try using Request.UrlReferrer
but it returns a null value.

thanks for advice.

I am using ASP.NET webform, C#.

Update
I have a website running.
I just want to know that from where do they come from when the user visited my website.

like image 629
alont Avatar asked Jan 21 '13 03:01

alont


People also ask

How do I find an old URL?

You can use the document. referrer property to get the previous page URL in JavaScript. It is a read-only property that returns the URL of the document that loaded the current document.

How can I get previous page in HTML?

In a web browser, the built-in JavaScript object window has an object called history containing the URLs a user has visited in their current browser window. You can use the history. back() method to tell the browser to go back to the user's previous page.

How do I find the previous URL in node JS?

You have to store in session. app. get('/url1', function(req, res){ res. send('ok') req.

How do I go back to previous page in JavaScript?

back() method loads the previous URL (page) in the history list. The history. back() method only works if a previous page exists.


1 Answers

What you're describing is the Referer HTTP header (originally a misspelling of "Referrer" that we're now stuck with). Browsers populate this field with the URI of any webpage that caused a user to navigate to a new page (such as by clicking an <a> hyperlink, a <form> submission, an action in a Flash object, etc). Not every user action will cause the header to be set, such as if an address is typed directly into the address bar, or if a link is opened in a desktop email messages.

Under ASP.NET this header is accessible by the Request.UrlReferrer property. However this property will be null if the HTTP header value is not a URI or if the field was not set by the client UA.

You must never depend on this mechanism because it is set by the client, and you must never trust the client ( http://en.wikipedia.org/wiki/Defensive_programming ). And as stated, not all visitors will have the Referer header set.

like image 110
Dai Avatar answered Sep 30 '22 19:09

Dai