Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Whenever I create an project with areas, I change my <code>Default</code> route as follows:</p> <pre><code> routes.MapRoute( "Default", // Route name "{controller}/{action}/{id}", // URL with parameters new { controller = "Home", action = "Index", id = UrlParameter.Optional }, // defaults null, // constraints new string[] { "MyApplication.Controllers" } // namespaces ); </code></pre> <p>The final parameter limits the default route to the controllers in the <code>MyApplication.Controllers</code> namespace. This insures that the Default route is limited to actions outside of any areas.</p> <p><strong>UPDATE</strong></p> <p>After a deep dive into the code, I discovered where the issue arises, and have a solution. Change your Default route to the following:</p> <pre><code>routes.Add( "Default", new Route("{controller}/{action}/{id}", new RouteValueDictionary( new { controller = "Home", action = "Index", id = UrlParameter.Optional } ), null, new RouteValueDictionary( new { Namespaces = new string[] { "MyApplication.Controllers" }, UseNamespaceFallback = false } ), new MvcRouteHandler() ) ); </code></pre> <p>The key is in adding the <code>UseNamespaceFallback</code> token. This will prevent the Default route from looking into any other namespaces. </p> <p>This is unexpected behavior, and it was a problem I was unaware of which affects a project I am working on. I will list it as an issue at aspnet.codeplex.com. I would not call this a bug, but the behavior definitely appears to breach the convetions for MVC routing.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload