Get the URL of the page that the asp.net error page was clicked on

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

I handle errors / exceptions in an event Application_Errorin Global.asax.

This works fine and I can get the URL where the error occurred.

I would like to get the page where this URL was located, clicking in turn gave me this error. You can say 1 level up.

So, for example, I have a page www.example.com/home-loans.aspxthat has a link that opens www.example.com/problem-url.aspx. That I click on this link www.example.com/problem-url.aspxgives an error, and I can correctly catch it with the url www.example.com/problem-url.aspx, but I can’t figure out how to write it www.example.com/home-loans.aspx.

If the link is called from outside the website (say, from a Google search), this value may be like nullor something else is possible.

Please let me know if you need a code for the event Application_Errorin Global.asax.

Please, help!

Thanks in advance!

+4
source share
1 answer

You might want to use the property UrlReferrer:

Request.UrlReferrer

This will give you the url in the header Refered.

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

+1
source

Source: https://habr.com/ru/post/1620265/


All Articles