HttpContext (VB) : HTTP Modules « Development « ASP.NET Tutorial






Imports Microsoft.VisualBasic
Imports System.Web

Public Class AppendMessage
    Implements 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_PreSendRequestContent(ByVal sender As Object, _
            ByVal e As EventArgs) Handles _application.PreSendRequestContent

        Dim message As String = "<!-- This page has been post processed at " & _
                                System.DateTime.Now.ToString() & _
                                " by a custom HttpModule.-->"

        _application.Context.Response.Output.Write(message)

    End Sub

End Class

File: Web.config

 
<configuration>
    <system.web>
      <httpModules>
        <add name="AppendMessage" type="AppendMessage, App_code" />
      </httpModules>
    </system.web>
</configuration>








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