I have next structure:
Controllers
Epic
PmController.cs
HomeController.cs
in my App_Start\\RouteConfig.cs I added: Update - added full method
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapRoute(
name: "Epic",
url: "Epic/{controller}/{action}",
defaults: new { controller = "Pm", action = "Index" }
);
routes.MapRoute(
name: "Default",
url: "{controller}/{action}/{id}",
defaults: new { controller = "Default", action = "Index", id = UrlParameter.Optional }
);
}
But somehow @Url.Action is always prefixed with "Epic". I'm using @Url.Action in other views/controllers like this:
<a href="@Url.Action("Links", "Home")">Links</a></li> // generates /Epic/Home/Links instead of just /Home/Links
LInks worked ok before adding this subfolder and route.
Additionally is it ok to use subfolders in Controllers or always use Areas .
Seems like you removed the default route, just add it again in your RouteConfig file:
routes.MapRoute(
"Default", // Route name
"{controller}/{action}/{id}", // URL with parameters
new { controller = "Home", action = "Index", id = UrlParameter.Optional } // Parameter defaults
);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.