0

What I have to do is get the URL of the previous page no matter what, I mean, if it comes from Google for instance, I have to get Google's URL and so forth... Can anybody help me?

I've tried Response.Redirect and also Request, ServerVariables["HTTP_REFERER"], however both of them returns null. I've tried JS as well using document.Referrer, but nothing's working.

Thanks in advance.

StriplingWarrior
  • 151,543
  • 27
  • 246
  • 315

2 Answers2

2

You can check the URL Referrer as explained in this SO post: Getting the HTTP Referrer in ASP.NET

But be aware that there won't always be a referrer. Some people consider this to be a privacy issue, and will set their browsers not to send a referrer header. The only way to know what URL the user came from "no matter what" is to have control over the generation of the URL in the first place and place a unique token on the URL so you can recognize which page the URL was generated for.

Community
  • 1
  • 1
StriplingWarrior
  • 151,543
  • 27
  • 246
  • 315
2

and with javascript / Jquery perhaps document.referrer as explained here

Community
  • 1
  • 1
Rob Allen
  • 2,871
  • 2
  • 30
  • 48