Copied to clipboard

Flag this post as spam?

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


  • Scott Ritshie 34 posts 99 karma points
    Feb 27, 2017 @ 14:34
    Scott Ritshie
    0

    Custom route *not* using the Umbraco pipeline

    Greetings,

    I've been pulling my hair out trying to find examples of getting a custom MVC 5 route to work with Umbraco 7.5.2. All documentation I see references using Umbraco data, but I need to get a custom Orders admin with CRUD to play in the same Umbraco site, while completely ignoring Umbraco altogether.

    I get an Umbraco 404 when loading anything within /Views/Orders/. I have added this folder to umbracoReservedPaths in Web.config.

    Controller:

    public class OrdersController : Controller
    {
        private OrdersContext db = new OrdersContext();
    
        // GET: Orders
        public ActionResult Index()
        {
            return View(db.OrdersDb.ToList());
        }
    }
    

    RouteConfig:

    public static void RegisterRoutes(RouteCollection routes)
    {
      routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
    
      routes.MapRoute(
        "Orders",
        "orders/{action}/{id}",
        defaults: new { controller = "Orders", action = "Index", id = UrlParameter.Optional }
      );    
    }
    

    Global.asax.cs:

    protected void Application_Started()
    {
      AreaRegistration.RegisterAllAreas();
    
      WebApiConfig.Register(GlobalConfiguration.Configuration);
      FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
      RouteConfig.RegisterRoutes(RouteTable.Routes);
    }
    

    The class type for Application_Started() is UmbracoApplication... not sure if that makes a difference. Thanks in advance for any help!

    Scott

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies