VB.NET - URL Rewriting



Cheat Sheet for URL Rewriting

    Dim Oldpath As String

    Dim NewPath As String

    Dim Incomming As HttpContext

    Dim indx As Integer

    Incomming = HttpContext.Current

    Oldpath = Incomming.Request.Path   

    If Oldpath.StartsWith("/OrderProduct/") Then

      Oldpath = Oldpath.Replace(".aspx", "")

      Oldpath = Oldpath.Replace("/OrderProduct/", "")

      indx = Oldpath.IndexOf("_")

      Oldpath = Oldpath.Remove(0, indx + 1)

      indx = Oldpath.IndexOf("_")

      Oldpath = Oldpath.Remove(0, indx + 1)

      NewPath = "/OrdeProduct.aspx?CategoryID=" & Oldpath & ""

      Incomming.RewritePath(NewPath)
    End If

Share |

 Cant find the page you are looking for?
 Help us to improve by adding the content that you are looking for.
 Leave a feedback
 We look forward to hear your comments and feedback.