Q:

Correct usage of MVC route id parameter

I would like to do the following in asp.net mvc:
myquizsite.com/quizzes              - list quizzes available
myquizsite.com/quizzes/quiz1        - list previous instances of quiz1
myquizsite.com/quizzes/quiz2        - list previous instances of quiz2
myquizsite.com/quizzes/quiz1/create - create new quiz1

Using the default route, this would mean that the "create" parameter gets passed into the action quiz1 to create a new instance of it. 
This seems odd to me so I am guessing there is a better way of doing it, though I am not sure how. 

A:

Using MVC Attribute routing
public QuizzesController :Controller
{
   [Route("quizzes/{id?}")] 
   public ActionResult Index(string id="")
   {
     if(!String. IsNullOrEmpty(id))
     {
       //to do  :Return quizzes available
     } 
     else
     {
       //To do :Return previous instances of id passed(Ex :quiz1/quiz2)
     }
   }
   [Route("quizzes/{id}/create")]
   public ActionResult Create(string id)
   {
      // to do  : return Create view for Id passed (Ex :quiz1/quiz2)
   }
}

You can enable attribute routing in the RegisterRoutes method in  RouteConfig.cs  file. 
public static void RegisterRoutes(RouteCollection routes)
{            
    routes. IgnoreRoute("{resource}.axd/{*pathInfo}");
    routes. MapMvcAttributeRoutes(); //This line enables attribute routing 
   //Default Route definition goes here
}

