472,145 Members | 1,615 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,145 software developers and data experts.

Global.asax Inheritance?

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
3 2617
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
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
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.

Similar topics

2 posts views Thread by Chuck | last post: by
22 posts views Thread by fd123456 | last post: by
12 posts views Thread by John M | last post: by
8 posts views Thread by Vishwanathan Raman | last post: by
8 posts views Thread by Rob T | last post: by
15 posts views Thread by =?Utf-8?B?UGF0Qg==?= | last post: by
reply views Thread by Saiars | last post: by
reply views Thread by leo001 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.