I am new to ASP.NET MVC3.
I set up several routes in Global.asax against which I generate some hyperlinks using the @ Html.ActionLink helper method.
All links get the correct visualization, except for the top one in the code below:
Global.asax
routes.MapRoute( null, "Section/{Page}/{SubPage}/{DetailPageName}", new { controller = "Base" } ); routes.MapRoute( null, "Section/{Page}/{SubPage}", new { controller = "Base", action = "SubPage" } ); routes.MapRoute( null, "Section/{Page}", new { controller ="Base", action="LandingPage"} ); routes.MapRoute( "Default", // Route name "{controller}/{action}", // URL with parameters new { controller = "Base", action = "Index" } // Parameter defaults );
ActionLink Code
@Html.ActionLink(@subPages.LinkedPageName, "DetailPage", new { Controller = "Base", Page = @ViewBag.PageName, SubPage = @Model.SubPageName, DetailPageName = subPages.LinkedPageName })
The above should choose the top route ie:
routes.MapRoute( null, "Section/{Page}/{SubPage}/{DetailPageName}", new { controller = "Base" } );
But he chooses the default route!
source share