I am trying to do a very simple thing. I want that when I type
Articles/list
then it should invoke the index action and list all the articles.
When I type
Articles/3
It should invoke the Index action and show the article detail. How can I achieve this? Here is my Global.asax routes:
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapRoute(
"Default", // Route name
"{controller}/{action}", // URL with parameters
new { controller = "Articles", action = "List" } // Parameter defaults
);
routes.MapRoute(
"ArticleDetail", // Route name
"{controller}/{id}", // URL with parameters
new { controller = "Articles", action="Index", id = "" } // Parameter defaults
);
listanddetailbe different actions on the Articles controller? Is there a particular reason you are trying to use the Index action for both?