By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
431,965 Members | 2,043 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 431,965 IT Pros & Developers. It's quick & easy.

HTTP Modules and global.asax

P: n/a
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
Nov 18 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
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

--
Regards,
Alvin Bruney
[ASP.NET MVP http://mvp.support.microsoft.com/default.aspx]
Got tidbits? Get it here... http://tinyurl.com/27cok
"Norton" <th********@hotmail.com> wrote in message
news:ei**************@TK2MSFTNGP09.phx.gbl...
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

Nov 18 '05 #2

P: n/a
HttpModules and the methods in your Global.asax are different things.
Your Global.asax is an instance of HttpApplication,
http://msdn.microsoft.com/library/de...ClassTopic.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/de...lrewriting.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

Norton wrote:
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


Nov 18 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.