public static void Register(IDependencyInjectionContainer container)
    {
        // Setup global sitemap loader
        MvcSiteMapProvider.SiteMaps.Loader = container.GetInstance<ISiteMapLoader>();

        // Check all configured .sitemap files to ensure they follow the XSD for MvcSiteMapProvider
        var validator = container.GetInstance<ISiteMapXmlValidator>();
        validator.ValidateXml(HostingEnvironment.MapPath("~/Mvc.sitemap"));

        // Register the Sitemaps routes for search engines
        XmlSiteMapController.RegisterRoutes(RouteTable.Routes);
    }
    public static void Register(IDependencyInjectionContainer container)
    {
// Setup global sitemap loader
        MvcSiteMapProvider.SiteMaps.Loader = container.GetInstance <ISiteMapLoader>();

// Check all configured .sitemap files to ensure they follow the XSD for MvcSiteMapProvider
        var validator = container.GetInstance <ISiteMapXmlValidator>();

        validator.ValidateXml(HostingEnvironment.MapPath("~/Mvc.sitemap"));

// Register the Sitemaps routes for search engines
        XmlSiteMapController.RegisterRoutes(RouteTable.Routes);
    }
        protected override IController GetControllerInstance(RequestContext requestContext, Type controllerType)
        {
            if (requestContext.HttpContext.Request.Url.ToString().EndsWith("favicon.ico", System.StringComparison.OrdinalIgnoreCase))
            {
                return(null);
            }
            if (requestContext.HttpContext.Request.Url.ToString().EndsWith(".map", System.StringComparison.OrdinalIgnoreCase))
            {
                return(null);
            }
            if (requestContext.HttpContext.Request.Url.ToString().EndsWith(".map;", System.StringComparison.OrdinalIgnoreCase))
            {
                return(null);
            }
            //if (requestContext.HttpContext.Request.Url.ToString().EndsWith(".css;", System.StringComparison.OrdinalIgnoreCase))
            //    return null;
            //if (requestContext.HttpContext.Request.Url.ToString().EndsWith(".js;", System.StringComparison.OrdinalIgnoreCase))
            //    return null;
            //try   //this error handling seems like it'd make sense, but it screws up our custom errors, so leave it blank for now
            //{
            IController ret = controllerType == null?
                              base.GetControllerInstance(requestContext, controllerType) :
                                  container.GetInstance(controllerType) as IController;

            return(ret);
            //}
            //catch (Exception ex)
//            {
//#if DEBUG
//                Console.WriteLine(ex.Message);
//#endif
//                return null;
//            }
        }
Beispiel #4
0
        protected override IController GetControllerInstance(RequestContext requestContext, Type controllerType)
        {
            if (requestContext.HttpContext.Request.Url.ToString().EndsWith("favicon.ico"))
            {
                return(null);
            }

            return(controllerType == null?
                   base.GetControllerInstance(requestContext, controllerType) :
                       container.GetInstance(controllerType) as IController);
        }
 public static T GetInstance <T>(this IDependencyInjectionContainer container)
 {
     return((T)container.GetInstance(typeof(T)));
 }