Global.asax and inheritance
<p>I have a parent app and a child app. Which currently have two separate Global.asax files. I'm trying to have this child app inherit from the parent app's Global.asax file. </p>

<p>So I have a file in my App_Code folder with all of the code in it as follows: </p>

<pre><code>namespace NsGlobalAsax
{
    public class GlobalAsax : System.Web.HttpApplication
    {
        public GlobalAsax()
        {
            //
            // TODO: Add constructor logic here
            //
        }



        void Session_Start(object sender, EventArgs e)
        {
            // add some data to the Session so permanent SessionId is assigned
            // otherwise new SessionId is assigned to the user until some data
            // is actually written to Session
            Session["Start"] = DateTime.Now;

            // get current context
            HttpContext currentContext = HttpContext.Current;

            if (currentContext != null)
            {
                if (!OnlineVisitorsUtility.Visitors.ContainsKey(currentContext.Session.SessionID))
                    OnlineVisitorsUtility.Visitors.Add(currentContext.Session.SessionID, new WebsiteVisitor(currentContext));
            }

        }

        void Session_End(object sender, EventArgs e)
        {
            // Code that runs when a session ends. 
            // Note: The Session_End event is raised only when the sessionstate mode
            // is set to InProc in the Web.config file. If session mode is set to StateServer 
            // or SQLServer, the event is not raised.

            if (this.Session != null)
                OnlineVisitorsUtility.Visitors.Remove(this.Session.SessionID);
        }



        public void Application_AuthenticateRequest(Object sender, EventArgs e)
        {
            String cookieName = FormsAuthentication.FormsCookieName;
            HttpCookie authCookie = Context.Request.Cookies[cookieName];

            if (null == authCookie)
            {//There is no authentication cookie.
                return;
            }

            FormsAuthenticationTicket authTicket = null;

            try
            {
                authTicket = FormsAuthentication.Decrypt(authCookie.Value);
            }
            catch (Exception ex)
            {
                //Write the exception to the Event Log.
                return;
            }

            if (null == authTicket)
            {//Cookie failed to decrypt.
                return;
            }

            //When the ticket was created, the UserData property was assigned a
            //pipe-delimited string of group names.
            String[] groups = authTicket.UserData.Split(new char[] { '|' });

            //Create an Identity.
            GenericIdentity id = new GenericIdentity(authTicket.Name, "LdapAuthentication");

            //This principal flows throughout the request.
            GenericPrincipal principal = new GenericPrincipal(id, groups);

            Context.User = principal;

        }
    }

}
</code></pre>

<p>Now I have my parent Global.asax file as follows: </p>

<pre><code>&lt;%@ Application Language="C#" CodeBehind="Global.asax.cs" src="Global.asax.cs"  Inherits="RootAsax.BaseGlobal"    %&gt;
</code></pre>

<p>and here is the codebehind file: </p>

<pre><code>namespace RootAsax
{
    public class BaseGlobal : NsGlobalAsax.GlobalAsax
    {}
}
</code></pre>

<p>now here is my child app Global.asax file: </p>

<pre><code>&lt;%@ Application Codebehind="Global.asax.cs" Inherits="FormsAuthAd.Global" Language="C#" %&gt;
</code></pre>

<p>and here is the codebehind file: </p>

<pre><code>namespace FormsAuthAd
{
    public class Global : NsGlobalAsax.GlobalAsax
    {
    }
}
</code></pre>

<p>Both classes in the codebehindfiles are inheriting from the source in the App_Code folder, however, the authentication status is not being passed from one app to another. For instance, if I login on the parent app, the authentication does not carry over to the child app. The opposite is also true. </p>

<p>I'm hoping I gave you guys enough detail.</p>

<p>Thanks! </p>

<p>EDIT: </p>

<p>Heinzi stated in the comments that this is not an inheritance issue. I need to figure out how to have the child app <strong>use</strong> the parent's Global.asax file. If i delete the child app's Global.asax file authentication does not work at all for the child app. Any ideas? </p>
