Reputation: 5201
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!
Upvotes: 4
Views: 784
Reputation: 1423
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.
Upvotes: 1