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.
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.
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.
You have to store in session. app. get('/url1', function(req, res){ res. send('ok') req.
back() method loads the previous URL (page) in the history list. The history. back() method only works if a previous page exists.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With