Copied to clipboard

Flag this post as spam?

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


  • Zack 12 posts 112 karma points
    Oct 02, 2015 @ 10:31
    Zack
    0

    Route Handling

    I'm working on a full MVC project that contains both Umbraco CMSed Views and non CMSed views.

    My route handing is currently like this.

        public class MyStartupHandler : IApplicationEventHandler
        {
            public void OnApplicationStarted(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext)
            {
                RegisterRoutes(RouteTable.Routes);
            }
    
            public static void RegisterRoutes(RouteCollection routes)
            {
                routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
    
                routes.MapRoute(
                    name: "Default",
                    url: "{controller}/{action}/{id}",
                    defaults: new { controller = "\\", action = "Index", id = UrlParameter.Optional }
                );
            }
    
            public void OnApplicationInitialized(
    UmbracoApplicationBase umbracoApplication,
    ApplicationContext applicationContext)
            {
            }
    
            public void OnApplicationStarting(
                UmbracoApplicationBase umbracoApplication,
                ApplicationContext applicationContext)
            {
            }
        }
    

    When i try to load the an Umbraco page. Current-Page is null or the views dont load leaving the pages blank. When i remove the the code inside the Register Routes umbraco views load fine but the Controllers (not Surface Controllers) don't work. and non Umbraco views don't load

    Looking for a way that will allow me to use Controllers to load views and Load the umbraco pages.

  • Lars-Erik Aabech 349 posts 1100 karma points MVP 7x c-trib
    Oct 02, 2015 @ 14:42
    Lars-Erik Aabech
    100

    If I'm not mistaken, you've taken over all URLs from Umbraco for the three first levels in your content-tree.

    If you prefix your route url with "myapplication" for instance, you should start getting content again. Although, you can't of course make a content node called "myapplication".

    This is all documented fairly well over here.

  • Zack 12 posts 112 karma points
    Oct 06, 2015 @ 07:58
    Zack
    0

    Thank you i will read the documentation.

Please Sign in or register to post replies

Write your reply to:

Draft