[ASP.NET]在类里存取Session、Server、Request、Response、AppInstance、Application

这个类方便在类里存取Session、Server、Request、Response、AppInstance、Application 时使用


这个类方便在类里存取Session、Server、Request、Response、AppInstance、Application 时使用


Public Class AspNetModule
    Implements IDisposable
    Private _Session As Web.SessionState.HttpSessionState
    Public Property Session() As Web.SessionState.HttpSessionState
        Get
            Return _Session
        End Get
        Set(ByVal value As Web.SessionState.HttpSessionState)
            _Session = value
        End Set
    End Property

    Private _Server As Web.HttpServerUtility
    Public Property Server() As Web.HttpServerUtility
        Get
            Return _Server
        End Get
        Set(ByVal value As Web.HttpServerUtility)
            _Server = value
        End Set
    End Property

    Private _Request As Web.HttpRequest
    Public Property Request() As Web.HttpRequest
        Get
            Return _Request
        End Get
        Set(ByVal value As Web.HttpRequest)
            _Request = value
        End Set
    End Property

    Private _Response As Web.HttpResponse
    Public Property Response() As Web.HttpResponse
        Get
            Return _Response
        End Get
        Set(ByVal value As Web.HttpResponse)
            _Response = value
        End Set
    End Property

    Private _AppInstance As Web.HttpApplication
    Public Property AppInstance() As Web.HttpApplication
        Get
            Return _AppInstance
        End Get
        Set(ByVal value As Web.HttpApplication)
            _AppInstance = value
        End Set
    End Property

    Private _Application As Web.HttpApplicationState
    Public Property Application() As Web.HttpApplicationState
        Get
            Return _Application
        End Get
        Set(ByVal value As Web.HttpApplicationState)
            _Application = value
        End Set
    End Property
    Public Sub New()
        _Server = Web.HttpContext.Current.Server
        _Response = Web.HttpContext.Current.Response
        _Request = Web.HttpContext.Current.Request
        _Session = Web.HttpContext.Current.Session
        _AppInstance = Web.HttpContext.Current.ApplicationInstance
        _Application = AppInstance.Application
    End Sub