I have 2 routes:
- college/{courseId}/{classId}
- college/{courseId}
But sometime when I try to input the 1st url type like college/course1/class2, it go to the 2nd action.
Can I fix route configuration to do it exactly? Here is my code:
[Route("college/{courseId}/{classId}")]
public void ActionResult example1(string courseId, string classId) {
return View();
}
[Route("college/{courseId}")]
public void ActionResult example2(string courseId) {
return View();
}
RouteConfig.cs file:
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
AreaRegistration.RegisterAllAreas();
routes.MapMvcAttributeRoutes();
//Default
routes.MapRoute(
name: "Default",
url: "{controller}/{action}/{id}",
defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
);
}