URL rewriting HttpModule (VB) : HTTP Modules « Development « ASP.NET Tutorial

Home
ASP.NET Tutorial
1.ASP.Net Instroduction
2.Language Basics
3.ASP.net Controls
4.HTML Controls
5.Page Lifecycle
6.Response
7.Collections
8.Validation
9.Development
10.File Directory
11.Sessions
12.Cookie
13.Cache
14.Custom Controls
15.Profile
16.Configuration
17.LINQ
18.ADO.net Database
19.Data Binding
20.Ajax
21.Authentication Authorization
22.I18N
23.Mobile
24.WebPart
25.XML
ASP.NET Tutorial » Development » HTTP Modules 
9.25.5.URL rewriting HttpModule (VB)
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 > 1Then
            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
9.25.HTTP Modules
9.25.1.Creating Custom HTTP Modules
9.25.2.HttpContext (C#)
9.25.3.HttpContext (VB)
9.25.4.URL rewriting HttpModule (C#)
9.25.5.URL rewriting HttpModule (VB)
9.25.6.The IHttpHandler page template (C#)
9.25.7.The IHttpHandler page template (VB)
9.25.8.Outputting an image from an HttpHandler (C#)
9.25.9.Outputting an image from an HttpHandler (VB)
9.25.10.Adding the HttpHandler configuration information to web.config
9.25.11.HttpModule Tester
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.