I have two MapRoute in global asax.`
routes.MapRoute(
"AutoGeneratedURLHandler", // Route name
"{modulepath}/{controller}/{action}/{id}", // URL with parameters
new { id = UrlParameter.Optional } // Parameter defaults
);
//default route
routes.MapRoute(
"Default", // Route name
"{controller}/{action}/{id}", // URL with parameters
new { controller = "Account", action = "Logon", id = UrlParameter.Optional } // Parameter defaults
);`
And I have two link on masterpage.
<li><%:Html.ActionLink("Card Types", "Index", "CardType", new { modulepath="CardManagement" },null)%></li>
<li><%:Html.ActionLink("Home Page", "Index", "Home")%></li>
After I click Card Types link, Home Page link becomes “/CardManagement/Home/Index” instead of “/Home/Index”.
Route values remember “modulepath” and add it auto to home page link. But I dont want this. How can I make it not add module path to url?
Instead of
ActionLink, you could use aRouteLinkand send it down your default route. Another option is to not use the ActionLink helper and just roll the link on your own: