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

Global.asax Inheritance?

P: n/a
I understand how Web.Config inheritance works between a parent application
and sub applications under the parent. But what I was wondering was if
there was a similar way to do the same thing for the Global.asax class?

Reason being, I am setting up user authentication and authorization. I have
coded up my Application_AuthenticateRequest method in the Global.asax file
to create an identity and principal which are attached to the Context User.
I have done this at my root web level. Under the root web, I then have
other sub applications in sub folders that are also protected by the same
authentication and authorization. I was hoping that I would not have to add
and maintain the same code in the global.asax files for each of these sub
apps in order to have access to the principal and identity objects set at
the parent level. Any thoughts?
TIA.
==============
Joe Reazor
Gorbel Inc.
email: joereaATgorbelDOTcom
Nov 18 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
Global.asax generates a class called "global". I believe you can create a
base class called "GlobalBase" and inherit all of your global.asax's from
that.
--
John Saunders
jo**************@hotmail.com

"Joe Reazor" <jo*******@belgor.com> wrote in message
news:ut*************@tk2msftngp13.phx.gbl...
I understand how Web.Config inheritance works between a parent application
and sub applications under the parent. But what I was wondering was if
there was a similar way to do the same thing for the Global.asax class?

Reason being, I am setting up user authentication and authorization. I have coded up my Application_AuthenticateRequest method in the Global.asax file
to create an identity and principal which are attached to the Context User. I have done this at my root web level. Under the root web, I then have
other sub applications in sub folders that are also protected by the same
authentication and authorization. I was hoping that I would not have to add and maintain the same code in the global.asax files for each of these sub
apps in order to have access to the principal and identity objects set at
the parent level. Any thoughts?
TIA.
==============
Joe Reazor
Gorbel Inc.
email: joereaATgorbelDOTcom

Nov 18 '05 #2

P: n/a
Hi Jeo,

As for the sharing a certain Global class among multi web applications, I
think John's suggestion that making a base
Global class derived fron the System.Web.HttpApplication class and put
those common authorization code in it. Then, in all those web applications,
derived their Global class from this Base Global class.

Also, beside using a base Global class, we can use the asp.net's HttpModule
to handle those application level events such as:
Application_Start
Application_BeginRequest
Application_AuthenticateRequest

Thus, we can use a certain HttpModule in multi web applications, only need
to register it in the web.config.
Here are some referencein MSDN on using HttpModule:

#Custom HttpModule Example
http://msdn.microsoft.com/library/en...tomhttpmodules.
asp?frame=true

http://cephas.net/blog/2003/09/25/as...y_example.html

Custom Authentication provider by implementing IHttpModule, IPrincipal and
IIdentity

Hope also helps. Thanks.

Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Get Preview at ASP.NET whidbey
http://msdn.microsoft.com/asp.net/whidbey/default.aspx


Nov 18 '05 #3

P: n/a
Steven,
Thanks for the help. This should be useful. I'll post if I have any
other questions.
==============
Joe Reazor
Gorbel Inc.
email: joereaATgorbelDOTcom
"Steven Cheng[MSFT]" <v-******@online.microsoft.com> wrote in message
news:A8**************@cpmsftngxa10.phx.gbl...
Hi Jeo,

As for the sharing a certain Global class among multi web applications, I
think John's suggestion that making a base
Global class derived fron the System.Web.HttpApplication class and put
those common authorization code in it. Then, in all those web applications, derived their Global class from this Base Global class.

Also, beside using a base Global class, we can use the asp.net's HttpModule to handle those application level events such as:
Application_Start
Application_BeginRequest
Application_AuthenticateRequest

Thus, we can use a certain HttpModule in multi web applications, only need
to register it in the web.config.
Here are some referencein MSDN on using HttpModule:

#Custom HttpModule Example
http://msdn.microsoft.com/library/en...tomhttpmodules. asp?frame=true

http://cephas.net/blog/2003/09/25/as...y_example.html

Custom Authentication provider by implementing IHttpModule, IPrincipal and
IIdentity

Hope also helps. Thanks.

Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Get Preview at ASP.NET whidbey
http://msdn.microsoft.com/asp.net/whidbey/default.aspx

Nov 18 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.