How to track which page request is redirected to asp.net

I have three pages calculator1.aspx, calculator2.aspx and Menu.aspx. On each page of the calculator, I have a button that redirects me to the menu page and to the menu page, I must return to the page Calculator1 or calculator2, from where the request was initiated. So how can I distinguish from which page my request will come in when im is on the menu page.

+3
source share
3 answers

It is best to check the title HTTP_REFERER. It can be faked, but more often than not it will be enough.

string referer = Request.ServerVariables["HTTP_REFERER"];
+1
source

URL.
calulator1.aspx write

Response.Redirect('menu.aspx?page=cal1')

calulator2.aspx write

Response.Redirect('menu.aspx?page=cal2')
+1

You can use the property Page.PreviousPageto get the page passed by the control to the current page.
Or using the property HttpRequest.UrlReferrerto retrieve the URL information of a previous client request associated with the current URL.

[Link]
Page.PreviousPage
HttpRequest.UrlReferrer

+1
source

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


All Articles