I was having a few problems redirecting users from a web form to the referrer that had taken them to this page.  The URL in Request.UrlReferrer was pointing to itself as I had already done a postback.  A little searching on Google brought up this little gem.  Thanks to Marco Bellinaso and Kevin Hoffman! :)


Private Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)
If Not Page.IsPostBack Then
‘ Save the referrer Url
ViewState(”ReferrerUrl”) = Request.UrlReferrer.ToString()
End If
End Sub

Protected Sub SaveAndReturn_Click(ByVal sender As Object, ByVal e As EventArgs)
‘ do something here, e.g. add/update some DB records

‘ redirect to the previous page
Response.Redirect(ViewState(”ReferrerUrl”).ToString())
End Sub