<%@ Application Language=" VB" %>
<script RunAt=" server" >
Protected Overloads Sub Application_BeginRequest(ByVal sender As Object, ByVal e As System.EventArgs)
' Recupero il path corrente
Dim CurrentPath As String = Request.Path.ToLower()
' Adesso riscriviamo l' url nel formato
' /gallery/31/
' Controllo se l' url deve essre riscritta
If CurrentPath.StartsWith(" /gallery/" ) Then
' Uso una semplice manipolazione della strinca
' rimuovo il carattere / dall' inizio
CurrentPath = CurrentPath.Trim(" /" )
Dim ars As String = CurrentPath.Substring(CurrentPath.IndexOf(" /" ))
dim ida as string = ars.replace(" /" ," " )
' Riscrivo l' url come una query
Dim MyContext As HttpContext = HttpContext.Current
MyContext.RewritePath(" ~/galleria2015/vedialbum.aspx?ida=" & ida)
End If
If CurrentPath.StartsWith(" /magazine/" ) Then
CurrentPath = CurrentPath.Trim(" /" )
Dim arq As String = CurrentPath.Substring(CurrentPath.IndexOf(" /" ))
dim id as string = arq.replace(" /" ," " )
Dim MyContext As HttpContext = HttpContext.Current
MyContext.RewritePath(" ~/giornale/articolo.aspx?id=" & id)
End If
End Sub
</script>