Note that there are some explanatory texts on larger screens.

plurals
  1. POMVC3: One controller, multiple routes
    primarykey
    data
    text
    <p>I have a MVC3 application with multiple areas. Every area is a different application module, but they share one common functionality - Reporting. So, I wrote a reporting controller and views in root area and wanted to attach them to all the areas using routing. This method worked well with MVC1, but I then upgraded to MVC3, the routes stopped working and always return 404.</p> <p>Routing structure is similar for every module/area:</p> <pre><code>Module1/Reports.aspx/ Module1/PreportView.aspx/{id} Module1/{controller}/{action} Module1/{controller}/{action}/{id} </code></pre> <p>and the route registration for module is made by the following method:</p> <pre><code>protected override void RegisterRoutes(AreaRegistrationContext context, string arearoot, string defaultControllerName){ context.MapRoute(arearoot + "Reports", arearoot + "/Reports.aspx", new { action = "Index", controller = "Reports" }, new string[] { "Controllers" }); //this should work in MVC3 according to docs context.MapRoute(arearoot + "ReportView", arearoot + "/ReportView.aspx/{id}", new { action = "Show", controller = "Controllers.ReportsController" });//this method worked in MVC1 context.MapRoute(arearoot, arearoot + "/{controller}.aspx/{action}", new { controller = defaultControllerName, action = "Index" }, GetRouteNamespaces()); context.MapRoute(arearoot + "ItemSpecific", arearoot + "/{controller}.aspx/{action}/{id}"); } protected string[] GetRouteNamespaces() { return new string[] { "Controllers.Module1" }; //returns proper namespace for each module } </code></pre> <p>I have tried to attach <strong>RouteDebugger</strong> (which fails because of .aspx extensions), and <strong>Glimpse</strong>, but none of them show me any problems, the routing table seemed to be OK, but when I try to navigate to reports, I always get the 404 error code.</p> <p>Any ideas?</p>
    singulars
    1. This table or related slice is empty.
    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.
 

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