Saturday, May 29, 2010

Hide Extention of Pages in url

In Global.aspx
Protected Sub Application_BeginRequest(ByVal sender As Object, ByVal e As System.EventArgs)
        Dim fullOrigionalpath As String = Request.Url.ToString()
        If (fullOrigionalpath.EndsWith("/Test/Default")) Then
            Context.RewritePath("/Test/Default.aspx")
        ElseIf (fullOrigionalpath.EndsWith("/Test/Default2")) Then
            Context.RewritePath("/Test/Default2.aspx")
        Else
            If fullOrigionalpath.EndsWith(".aspx") Or fullOrigionalpath.EndsWith(".php") Then Context.RewritePath("/Test/CustomError.aspx")
       End If
    End Sub
  
    Protected Sub Application_AuthenticateRequest(ByVal sender As Object, ByVal e As System.EventArgs)
        If Request.UserHostAddress.StartsWith("198.168") Then
            Context.RewritePath("/Test/right.aspx")
        End If
    End Sub

No comments:

Post a Comment