M
msnews.microsoft.com
Hi... I'm learning about HTTPModules, so please allow me a beginner's
question.
I read that "you gain low-level access to the HTTPRequests and responses
processed by the ASP.NET framework". But... I'm confused, because in this
example they use "AuthenticateRequest" and "EndRequest"... (they write code
for redirecting the user to a login page if the address is like
"YourSite.com/contents.aspx" instead of
"YourSite.com/contents.aspx?Username=Blah").
Imports System.Web
Public Class AuthenticationModule
Implements IHttpModule
Public Sub Init(ByVal context As System.Web.HttpApplication) Implements
System.Web.IHttpModule.Init
AddHandler context.AuthenticateRequest, AddressOf Me.OnEnter
AddHandler context.EndRequest, AddressOf Me.OnLeave
End Sub
Public Sub Dispose() Implements System.Web.IHttpModule.Dispose
End Sub
Public Sub OnEnter(ByVal s As Object, ByVal e As EventArgs)
End Sub
Public Sub OnLeave(ByVal s As Object, ByVal e As EventArgs)
End Sub
End Class
But my question is this: why do I need to write a HTTPModule at all ?
Really... I can write the exact same code in Global.asax, right ? Or is it
*NOT* the same ?
Thank you,
Alex
question.
I read that "you gain low-level access to the HTTPRequests and responses
processed by the ASP.NET framework". But... I'm confused, because in this
example they use "AuthenticateRequest" and "EndRequest"... (they write code
for redirecting the user to a login page if the address is like
"YourSite.com/contents.aspx" instead of
"YourSite.com/contents.aspx?Username=Blah").
Imports System.Web
Public Class AuthenticationModule
Implements IHttpModule
Public Sub Init(ByVal context As System.Web.HttpApplication) Implements
System.Web.IHttpModule.Init
AddHandler context.AuthenticateRequest, AddressOf Me.OnEnter
AddHandler context.EndRequest, AddressOf Me.OnLeave
End Sub
Public Sub Dispose() Implements System.Web.IHttpModule.Dispose
End Sub
Public Sub OnEnter(ByVal s As Object, ByVal e As EventArgs)
End Sub
Public Sub OnLeave(ByVal s As Object, ByVal e As EventArgs)
End Sub
End Class
But my question is this: why do I need to write a HTTPModule at all ?
Really... I can write the exact same code in Global.asax, right ? Or is it
*NOT* the same ?
Thank you,
Alex