Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Multi level Global.asax inheritance
Message
De
24/10/2008 03:33:41
 
 
À
23/10/2008 23:41:44
Information générale
Forum:
ASP.NET
Catégorie:
Autre
Versions des environnements
Environment:
VB 9.0
OS:
Vista
Network:
Windows 2008 Server
Database:
MS SQL Server
Divers
Thread ID:
01356799
Message ID:
01356820
Vues:
18
>Hi,
>Does ASP.NET Global.asax support multi level inheritance? I have code as below. When I run my web app, only the code in MyGlobal executed, but not BaseGlobal. Any ideas? Thank hyou
>
>
>public class BaseGlobal : HttpApplication 
>{ 
>   void Application_Start(object sender, EventAgrs e)
>   {
>      // Set breakpoint string abc = ""; 
>   } 
>}
>
>public class MyGlobal : BaseGlobal 
>{ 
>   void Application_Start(object sender, EventAgrs e) 
>   { 
>      // Set breakpoint string dddd = "";
>   } 
>} 
>
>//Global.asax 
>&lgt;%@ Application Language="C#" Inherits="MyGlobal" %
>
Hi,

Several things:
(a) Make Application_Start protected and virtual in BaseGlobal so that it can be overridden.
(b) In MyGlobal mark it as 'protected override'
(c) Call the parent class specifically from MyGlobal.Application_Start
(d) Spell EventArgs correctly :-}
    public class BaseGlobal : HttpApplication
    {
        protected virtual void Application_Start(object sender, EventArgs e)
        {
            // Set breakpoint string abc = "";
            
        }
    }

    public class MyGlobal : BaseGlobal
    {
        protected override void Application_Start(object sender, EventArgs e)
        {
            // Add code as required
            base.Application_Start(sender,e);
            // Add code as required
        }
    } 
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform