umbraco / UmbracoDocs

The official Umbraco Documentation
https://docs.umbraco.com
MIT License
269 stars 780 forks source link

This routing example causes issues with ModelsBuilder #1710

Closed Slipoch closed 4 years ago

Slipoch commented 5 years ago

This is the page with issues: https://github.com/umbraco/UmbracoDocs/edit/master/Reference/Routing/Authorized/index.md

The C# example on this page seems to cause a break in modelsbuilder as then the modelsbuilder attempts to find the route from your App_Plugin folder rather than it's own.

Slipoch commented 5 years ago

Ok, maybe put in a constraint into the example to limit it's routing to the specific controller and not interfere.

Constraint works.

nul800sebastiaan commented 5 years ago

Sounds good! Do you have an example of the constraint you added please?

Slipoch commented 5 years ago
RouteTable.Routes.MapRoute("[yourPluginName]", 
    _globalSettings.GetUmbracoMvcArea() + "/backoffice/[yourpluginname]/{controller}/{action}/{id}",
         new {
             controller = "[yourcontrollername]",
             action = "Index",
             id = UrlParameter.Optional },
    constraints: new { controller="[yourcontrollername]" });
sofietoft commented 4 years ago

Hi all 👋

It's been a while since I've seen any activity on this one. Sounds like a code snippet that needs to be updated - I know it's been a while, but perhaps you'd still be up for it @Slipoch ? 😄 Let me know.

sofietoft commented 4 years ago

I've added a PR to include the constraint in the code sample: #2731