views:

264

answers:

3

I have an ASP.Net application which generates short url for sharing. I want to track the url from where (source) click occured when it hits my asp.net page. I tried using Context.Request.UrlReferrer.AbsoluteUri but all I get from it is null.

Any ideas?

TIA

A: 

When the page first time load, you need to store URL referrer value somewhere hiddenfield or some variable (might be after postback)

Note: When your page is postback I think its value set to null

Muhammad Akhtar
Thank you - I had a response.redirect code which was setting it to null
Murali Bala
A: 

Not quite as clean, but you could use Request.Headers["Referer"]. Should be the same as using Context.Request, but I've found the behavior to be different.

Agent_9191
A: 

Don't forget that the referrer will sometimes be null for things like search engines, or people behind corporate firewalls that remove some HTTP headers.

pattermeister