4

I am not sure if this is possible but I have a requirement so had to ask!

I am handling errors/exceptions in Application_Error event in Global.asax.

This is working fine and I am able to get the url in which the error occurred.

I would like to get the page on which this url resided clicking of which in turn gave me this error. You can say 1 level up.

So, for example I have a page say www.example.com/home-loans.aspx on which there is a link which opens www.example.com/problem-url.aspx. Which I click this link www.example.com/problem-url.aspx throws an error and I am able to correctly catch this along with the url www.example.com/problem-url.aspx but I am not able to figure how to capture www.example.com/home-loans.aspx.

If the link is clicked from outside the website (say from a google search) then this value can come as null or whatever is possible.

Please let me know if you need the code for Application_Error event in Global.asax.

Please help!

Thanks in advance!

samar
  • 5,021
  • 9
  • 47
  • 71

1 Answers1

1

You may want to consider using the UrlReferrer property:

Request.UrlReferrer

This will give you the URL in the Refered header.

However, the header may or may not always be available.

Community
  • 1
  • 1
Jia Jian Goi
  • 1,415
  • 3
  • 20
  • 31
  • Seems to be working. Have handled null for this property if it is not available. Will try out a few days and update you. Upvote from me. – samar Dec 16 '15 at 09:06
  • Yes it did! Accepting answer! Thanks a million! Will comment if I need any clarifications! Should be fine right? – samar Dec 23 '15 at 10:44