返回顶部

收藏

url重写示例

更多
Public Class Rewrite
    Implements System.Web.IHttpModule

    Public Sub Dispose() Implements System.Web.IHttpModule.Dispose

    End Sub

    Public Sub Init(ByVal context As System.Web.HttpApplication) Implements System.Web.IHttpModule.Init

        AddHandler context.BeginRequest, AddressOf ReWrite_BeginRequest

    End Sub

    Public Sub ReWrite_BeginRequest(ByVal sender As Object, ByVal args As System.EventArgs)
        Dim l_httpApp As System.Web.HttpApplication = sender

        If InStr(l_httpApp.Request.Path.ToLower, "news/") > 0 Then
            'Wir haben was gefunden
            l_httpApp.Context.RewritePath("/sites/news.aspx?ID=" & Mid(l_httpApp.Request.Path.ToLower, InStr(l_httpApp.Request.Path.ToLower, "news/") + 5, 36))
        End If

    End Sub
End Class

Änderungen in der web.config:

  <system.web>

    <httpModules>
        <add type="BET.Web.URLRewrite.Rewrite,BET.Web.URLRewrite" name="BET.Web.URLRewrite" />
    </httpModules>
  </system.web>
//该片段来自于http://outofmemory.cn

标签:VB,基础

收藏

0人收藏

支持

0

反对

0