Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Eric Herlitz 97 posts 129 karma points
    Sep 09, 2012 @ 16:09
    Eric Herlitz
    0

    Extending global.asax in Umbraco 4.7 for dependency injection

    Hi,

    Im using umbraco v 4.7.1 (Assembly version: 1.0.4281.20201) and have a project where I must extend the global.asax file. 

    Please not the followin

    Here is my implementation,
    using Project.Umbraco.DependencyInjection;
    using Project.Umbraco.IoC;
    using Microsoft.Practices.Unity;
    using System;
    using System.Diagnostics;
    using umbraco;
    
    namespace Project.Umbraco.App_Start
    {
        public class MyGlobal : Global, IContainerAccessor
        {
            /// <summary>
            /// Returns the IoC container
            /// IContainerAccessor
            /// </summary>
            public IUnityContainer Container
            {
                get
                {
                    return MvcUnityContainer.Instance.Container;
                }
            }
    
            protected override void Application_Start(object sender, EventArgs e)
            {
                base.Application_Start(sender, e);
                Debug.WriteLine("Application start");
            }
    
            protected override void Application_BeginRequest(object sender, EventArgs e)
            {
                base.Application_BeginRequest(sender, e);
                Debug.WriteLine("Application start");
            }
            //protected void Session_Start(object sender, EventArgs e) {}
            //protected void Application_AuthenticateRequest(object sender, EventArgs e) {}
            //protected void Application_Error(object sender, EventArgs e) {}
            //protected void Session_End(object sender, EventArgs e) {}
            //protected void Application_End(object sender, EventArgs e) {}
        }
    }

    The implementation seems as if should work, maybe I've just placed this in the wrong namespace or something?

    Thanks for any help

    Eric

Please Sign in or register to post replies

Write your reply to:

Draft