Imports Microsoft.VisualBasic
Imports System.Web
Public Class SimpleRewriter
Implements System.Web.IHttpModule
Dim WithEvents _application As HttpApplication = Nothing
Public Overridable Sub Init(ByVal context As HttpApplication) _
Implements IHttpModule.Init
_application = context
End Sub
Public Overridable Sub Dispose() Implements IHttpModule.Dispose
End Sub
Public Sub context_BeginRequest(ByVal sender As Object, ByVal e As EventArgs) _
Handles _application.BeginRequest
Dim requesturl As String = _
_application.Context.Request.Path.Substring(0, _
_application.Context.Request.Path.LastIndexOf("/"c))
Dim parameters() As String = _
requesturl.Split(New [Char]() {"/"c}, _
StringSplitOptions.RemoveEmptyEntries)
If (parameters.Length > 1) Then
Dim firstname As String = parameters(1)
Dim lastname As String = parameters(2)
_application.Context.RewritePath("~/unfriendly.aspx?firstname=" & _
firstname & "&lastname=" & lastname)
End If
End Sub
End Class
|