⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 class1.vb

📁 對c#初學者參考..為課題asp.net 2.0教材代碼
💻 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))

        'Here is where we parse the original request url to determine
        ' the querystring parameters for the unfriendly url
        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)

            'Rewrite the request path   
            _application.Context.RewritePath("~/unfriendly.aspx?firstname=" & _
                firstname & "&lastname=" & lastname)
        End If
    End Sub

End Class

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -