ASP.NET has a very sophisticated methods to navigate from one page to another page but there isn’t any method which allow programmers to wire the page to return to the previous page you came from. Think of the situation of page used in the workflow and later same page can be accessed from the other areas of the system and same button should navigate to the user to the previous page regardless of what subsystem user visited from.
I have used (as many of you might have) following pattern in past and it worked great. Though of sharing this for wider community.
Create a Textbox or Session variable. Here I’m using a textbox and make the visible property of the textbox to false.
Write the below code in the Page_Load event()
In the BACK or CANCEL or FINISH button click event handler, use the following code
string requestPage = this.txtRequestUri.Text.ToString();