Developer forum

Forum » Development » Read referral page

Read referral page

Adrian Ursu Dynamicweb Employee
Adrian Ursu
Reply

Hi guys,

I was wondering if there is any way I can read the previous URL, basically, the URl that the user came from before accessing the current page.

I mainly need to identify the page the user comes from when requesting a quote.

Any idea?

Thank you,
Adrian


Replies

 
Lars Larsen
Lars Larsen
Reply
This post has been marked as an answer

Hi Adrian

What about System.Web.HttpContext.Current.Request.UrlReferrer.ToString() ?

Votes for this answer: 1
 
Adrian Ursu Dynamicweb Employee
Adrian Ursu
Reply

Hi Lars,

Thank you for that. For some reason I keep forgetting I can always use .NET methods :)

Thank you very much.

Adrian

 
Lars Larsen
Lars Larsen
Reply

smiley

 
Imar Spaanjaars Dynamicweb Employee
Imar Spaanjaars
Reply

Just be carefull; I think UrlReferrer could be null in which case ToString() will fail.

 
Adrian Ursu Dynamicweb Employee
Adrian Ursu
Reply

Hi Imar,

Thank you.

I already go the error and wrapped the variable in a null check.

Thank you,

Adrian

 
Nicolai Pedersen
Reply

And the URL referer is a very common xxs candidate. Like these:

Connection:

keep-alive

Accept:

Text/Html,Application/Xhtml Xml,Application/Xml;Q=0.9,*/*;Q=0.8

Accept-Encoding:

gzip

Accept-Language:

en-us,en;q=0.5

Host:

doc.dynamicweb.com

Referer:

https://doc.dynamicweb.com/Admin/Public/Download.aspx?file="><script >alert(String.fromCharCode(88,83,83))</script>

User-Agent:

Mozilla/5.0 (Windows NT 10.0; WOW64; Rv:50.0) Gecko/20100101 Firefox/50.0

 
Adrian Ursu Dynamicweb Employee
Adrian Ursu
Reply

Hi Nicolai,

That's a valid concern.

What would be the alternative?

Thank you,
Adrian

 
Nicolai Pedersen
Reply

It depends on what you are doing.

DW should catch most xxs attempts, but you have to ensure that it contains a valid value depending on what you are using it for. If your render out a link with the referer, you should ensure that it does not contain i.e. html.

An alternative is that whatever is causing a quote, will also send the page id the user comes from and then you can use that to find your way back.

NP

 
Adrian Ursu Dynamicweb Employee
Adrian Ursu
Reply

Hi Nicolai,

In this particular case, I am storing the referral URL on a hidden field on a Request Offer form.

The admin wants to know the initial page that the users started from when asking for a quote.

The value is not used anywhere else for redirect or other purpose. It is just stored in a hidden field on a form.

Thank you,
Adrian

 
Imar Spaanjaars Dynamicweb Employee
Imar Spaanjaars
Reply

I wouldn't depend on the referrer anyway. It's often stripped out by security software on the user's local machine. What if you store the current URL in a hidden field, post to the next page and retrieve it there?

 
Adrian Ursu Dynamicweb Employee
Adrian Ursu
Reply

Hi Imar,

I am actually considering this.

I was thinking about sending the QueryString parameters and create the friendly URl in the Form template instead.

Just to prevent weird rendering.

I am still trying to figure out the best way.

I initially hoped there would be a DW method to get the Referral page.

Since there is none, I will have to either use the .NET method or use POST.

Thank you,
Adrian

 

You must be logged in to post in the forum