Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<blockquote> <p>This does not works when the url is like this localhost:2474/SOProblems/SubFolder/ChildController/index</p> </blockquote> <p>That's normal. You route pattern looks like this: <code>SubFolder/ChildController</code> and not <code>SubFolder/ChildController/index</code>. In addition to that you defined your route in the WRONG place. You defined it in your main route definitions and not in your area route definitions. So get rid of the custom route definition from your main routes and add it to the <code>SOProblemsAreaRegistration.cs</code> file (which is where your <code>SOProblems</code> routes should be registered):</p> <pre><code>public override void RegisterArea(AreaRegistrationContext context) { context.MapRoute( "SubFolderRoute", "SOProblems/SubFolder/ChildController", new { controller = "ChildController", action = "Index" }, new[] { "Practise.Areas.SOProblems.Controllers.SubFolder" } ); context.MapRoute( "SOProblems_default", "SOProblems/{controller}/{action}/{id}", new { action = "Index", id = UrlParameter.Optional } ); } </code></pre> <p>Also since your route pattern (<code>SOProblems/SubFolder/ChildController</code>) doesn't have the possibility to specify an action name, you can only have one action on this controller and that would be the default action that you registered (<code>index</code>) in this case.</p> <p>If you wanted to have more actions on this controller and yet index be the default one you should include that in your route pattern:</p> <pre><code>context.MapRoute( "SubFolder", "SOProblems/SubFolder/ChildController/{action}", new { controller = "ChildController", action = "Index" }, new[] { "Practise.Areas.SOProblems.Controllers.SubFolder" } ); </code></pre> <p>In both cases your main route definition could remain with their default values:</p> <pre><code>public static void RegisterRoutes(RouteCollection routes) { routes.IgnoreRoute("{resource}.axd/{*pathInfo}"); routes.MapRoute( "Default", "{controller}/{action}", new { controller = "Home", action = "Index" } ); } </code></pre>
 

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