asp.net mvc 4 - MVC 4 RouteConfig -
i have mvc 4 web project , wrote code in routeconfig.cs
public static void registerroutes(routecollection routes) { routes.ignoreroute("{resource}.axd/{*pathinfo}"); routes.maproute( name: "default", url: "{controller}/{action}/{id}", defaults: new { controller = "home", action = "index", id = urlparameter.optional } ); routes.maproute( "course", "{controller}/{courseid}", new { action = "index" } ); }
and want link [site-root]/course/15 not working (http 404 error). how can solve problem? thanks
seeing "course" type of resource you're trying set up, i'd create coursecontroller e.g. index action , set in routeconfig this:
routes.maproute( "course", "course/{courseid}", new { action = "index", controller="course" } );
Comments
Post a Comment