How to map Home/Action/id to just action/id?

后端 未结 3 1412
谎友^
谎友^ 2021-01-13 13:26

At the moment I have just this route defined

 routes.MapRoute(
                \"Default\",                                                
                \         


        
3条回答
  •  挽巷
    挽巷 (楼主)
    2021-01-13 13:39

     routes.MapRoute(
                    "NewRoute",                                                
                    "{id}",                           
                    new { controller = "Home", action = "Index", id = "" } 
                    );
    

    try that, as long as you default the controller and action it should work. Don't forget when generatig links with Html.Action to use the new route name.

    Apologies for formatting written on my iPhone

提交回复
热议问题