Having trouble with a simple MVC route

前端 未结 2 590
谎友^
谎友^ 2021-01-07 00:50

Having some trouble with some routes. I don\'t fully understand the MVC routing system so bear with me.

I\'ve got two controllers, Products and Home (with more to co

2条回答
  •  心在旅途
    2021-01-07 01:30

    Have you tried:

     routes.MapRoute(
     "Home_About", 
     "About", 
     new { controller = "Home", action = "About" } );
    
     routes.MapRoute(
     "Default",
     "{controller}/{action}/{id}",
     new { controller = "home", action = "index", id = UrlParameter.Optional }
     );
    

    Products should still be handled by the Default route, while the first one can handle your About route.

提交回复
热议问题