2

I catch all 404 responses returned from my site (aspx 404 page) and log them. Is there a way for me to know if the request was made directly from the browsers' address bar, or referenced by clicking a link - or if it was requested as part of another page?

JNF
  • 3,696
  • 3
  • 31
  • 64

1 Answers1

2

Check the HttpContext.Current.Request.UrlReferrer property. If the request was a result of a link from another page the property should contain that page's URI. If the address was entered directly that property should be blank.

Good idea by the way to log dead links.

Anders Abel
  • 67,989
  • 17
  • 150
  • 217
  • 2
    as an aside - be aware that "some" search engines / robots / etc. do lie for the referrer. – Rowland Shaw May 01 '12 at 07:26
  • I guess I wasn't so clear. I'm interested in links as much as direct browser requests. I'm trying to separate requests for pages from requests for components (i.e. a wouldn't be found, but it's important for me to know that there is no link on my site to 'js.aspx' (i.e. 42 ), just a wrong script tag. – JNF May 01 '12 at 07:30