HTTP Modules and global.asax

N

Norton

I understand how to create HTTP modules that can be used to add
functionality to a website but there are a few things I don't understand.

If I create an HTTP Module and I want it to intercept a call to
AuthenticateRequest, I know that in my init function for my HTTP module, I
can add a handler to this method name and then use this event handler
delegate to call my own function.

I saw some sample code though that mentioned (for some reason I'm not sure)
that in the global.asax, you could have code (a function name) like
'MyHTTPModuleName_AutheticateRequest'.

Does this make any sense at all, or maybe I was seeing things? Why would you
add a function to global.asax that had the module name in front of it if you
intend to use a module to contain the logic?

Thanks!

Norton
 
A

Alvin Bruney [MVP]

i haven't seen the article, but i am guessing they were speaking in terms of
mapping the event to your own function. got the article nearby? that would
help
 
S

Shan Plourde

HttpModules and the methods in your Global.asax are different things.
Your Global.asax is an instance of HttpApplication,
http://msdn.microsoft.com/library/d...l/frlrfSystemWebHttpApplicationClassTopic.asp.
HttpApplication exposes a series of events that you can tie event
handlers to, such as AuthenticateRequest. As the MSDN help for
HttpApplication states,
"An application executes events that are handled by modules or user code
defined in the global.asax file"

In your global.asax.cs you have the auto code generated methods that
VS.NET creates. You don't have to have them there, and they don't have
to be named based on your HttpModule names. They are event handlers for
the given events that HttpApplication exposes. Your HttpModules will
also have their own event handlers to do stuff during the events that
HttpApplication exposes, but the global.asax.cs event handler naming is
totally arbitrary.

I found a good introduction to HttpModules and HttpApplication event
handling from the URL Rewriting article that Microsoft has,
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnaspp/html/urlrewriting.asp.
Worth a read if you haven't already...helps to understand the difference
betwen the two, and shows you how to incorporate URL rewriting...good
article.

Shan
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,020
Latest member
GenesisGai

Latest Threads

Top