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

📄 authmodule.vb

📁 asp.net技术内幕的书配源码
💻 VB
字号:
Imports System
Imports System.Web
Imports Microsoft.VisualBasic

Namespace myModules

Public Class AuthModule
Implements IHttpModule

Public Sub Init( ByVal myApp As HttpApplication ) _
Implements IHttpModule.Init
  AddHandler myApp.AuthenticateRequest, AddressOf Me.OnEnter
  AddHandler myApp.EndRequest, AddressOf Me.OnLeave
End Sub

Public Sub Dispose() _
Implements IHttpModule.Dispose
End Sub

Public Sub OnEnter( s As Object, e As EventArgs )
  Dim objApp As HttpApplication
  Dim objContext As HttpContext
  Dim strPath As String

  objApp = CType( s, HttpApplication )
  objContext = objApp.Context
  strPath = objContext.Request.Path.ToLower()

  If Right( strPath, 10 ) <>  "login.aspx" Then
    If objContext.Request.Params( "username" ) = Nothing Then
      objContext.Response.Redirect( "login.aspx" )
    End If
  End If
End Sub

Public Sub OnLeave( s As Object, e As EventArgs)
End Sub

End Class
End Namespace

⌨️ 快捷键说明

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