Global.asax Inheritance?

Discussion in 'ASP .Net Security' started by Joe Reazor, May 21, 2004.

  1. Joe Reazor

    Joe Reazor Guest

    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
     
    Joe Reazor, May 21, 2004
    #1
    1. Advertising

  2. 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


    "Joe Reazor" <> wrote in message
    news:...
    > 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
    >
    >
     
    John Saunders, May 21, 2004
    #2
    1. Advertising

  3. Joe Reazor

    Joe Reazor Guest

    Yeah that makes sense. Should have thought of that. The only downside I
    see with that is the fact that then anytime I want to create a new
    application that will be under the same root web, I'll need to remember to
    change that inheritance. And even worse anyone else in my group will have
    to remember. Doesn't seem very reliable/enforceable in that sense.


    ==============
    Joe Reazor
    Gorbel Inc.
    email: joereaATgorbelDOTcom

    "Eric Marvets" <> wrote in message
    news:...
    > Have you tried creating a class that inherits from

    System.Web.HttpApplication and implements that functionality? Then you
    could have you root and sub apps' Global.asax inherit from your custom class
    instead of HttpApplication.
    >
    > -Eric
     
    Joe Reazor, May 21, 2004
    #3
  4. Joe Reazor

    Eric Marvets Guest

    This is a long shot, but you could look at Enterprise Templates. I don't
    know enough about them to tell you if you could force all ASP.NET projects
    to use the custom class. I think you should be able to default it at least.

    Besides, what ever you miss is always caught during testing <g>

    --
    Eric Marvets
    Principal Consultant

    the bang project

    <shameless self promotion>

    Email for Information on Our Architecture and
    Mentoring Services

    </shameless self promotion>

    "Joe Reazor" <> wrote in message
    news:#...
    > Yeah that makes sense. Should have thought of that. The only downside I
    > see with that is the fact that then anytime I want to create a new
    > application that will be under the same root web, I'll need to remember to
    > change that inheritance. And even worse anyone else in my group will have
    > to remember. Doesn't seem very reliable/enforceable in that sense.
    >
    >
    > ==============
    > Joe Reazor
    > Gorbel Inc.
    > email: joereaATgorbelDOTcom
    >
    > "Eric Marvets" <> wrote in message
    > news:...
    > > Have you tried creating a class that inherits from

    > System.Web.HttpApplication and implements that functionality? Then you
    > could have you root and sub apps' Global.asax inherit from your custom

    class
    > instead of HttpApplication.
    > >
    > > -Eric

    >
    >
     
    Eric Marvets, May 21, 2004
    #4
  5. Hi Jeo,

    I've also found another thread in Newsgroups:
    microsoft.public.dotnet.framework.aspnet.
    on the same issue and I've also posted a reply in that one. I'd appreciate
    if you also have a look there. Also, if you have any other ideas or
    question, please feel free to post here or in that one. 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
     
    Steven Cheng[MSFT], May 22, 2004
    #5
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. VSK
    Replies:
    1
    Views:
    790
    Alvin Bruney
    Jul 29, 2003
  2. Joe Reazor

    Global.asax Inheritance?

    Joe Reazor, May 21, 2004, in forum: ASP .Net
    Replies:
    3
    Views:
    4,908
    Joe Reazor
    May 24, 2004
  3. =?Utf-8?B?Q2h1Y2s=?=

    Global.asax inheritance

    =?Utf-8?B?Q2h1Y2s=?=, Jul 20, 2004, in forum: ASP .Net
    Replies:
    2
    Views:
    486
    =?Utf-8?B?Q2h1Y2s=?=
    Jul 21, 2004
  4. =?Utf-8?B?YmNoYXJsZXM=?=

    global.asax and global.asax.cs

    =?Utf-8?B?YmNoYXJsZXM=?=, Oct 4, 2004, in forum: ASP .Net
    Replies:
    5
    Views:
    841
    =?Utf-8?B?YmNoYXJsZXM=?=
    Oct 5, 2004
  5. Mark Rae

    Global.asax / Global.asax.cs in v2

    Mark Rae, May 23, 2006, in forum: ASP .Net
    Replies:
    6
    Views:
    3,165
    Mark Rae
    May 23, 2006
Loading...

Share This Page