Redirect to previous page
The trick is to store the Request.UrlReferrer in ViewState during the page load.
protected void Page_Load(object sender, EventArgs e)
{
if (Page.IsPostBack) return;
ViewState["PreviousPageUrl"] = Request.UrlReferrer.ToString();
}
protected void btnBack_Click(object sender, EventArgs e)
{
Page.Response.Redirect(ViewState["PreviousPageUrl"]
.ToString());
}
Written by Pedro Tavares
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Asp.net
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#