Tips and tricks for .NET using ASP and VB code.

Redirect to another page and preserve any passed parameters.

    Protected Sub Page_Init(sender As Object, e As System.EventArgs) Handles Me.Init
'Redirect to another page and preserve any passed parameters.
Dim ThisPageUrl As String = Request.RawUrl
Dim ThisPageFile As String = IO.Path.GetFileName(Request.Path)
Dim RedirectPageFile As String = "RedirectPage.aspx"
Dim RedirectPageUrl As String = ThisPageUrl.Replace(ThisPageFile, RedirectPageFile)
Response.Redirect(RedirectPageUrl)
End Sub

No comments:

Post a Comment

Search This Blog