关于ASP.NET MVC路由的问题

时间:2010-08-05 13:53:26

标签: asp.net-mvc asp.net-mvc-routing

我有动作SomethingEditor,SomethingDelete,SomethingSave,SomethingAdd,我想设置这些路由:site / Something / Editor,site / Something / Delete,site / Something / Save etc

我怎么做?

1 个答案:

答案 0 :(得分:1)

使用以下路线:

routes.MapRoute(null, "site/Something/Editor", new { controller = "Something", action = "SomethingEditor" });
routes.MapRoute(null, "site/Something/Delete", new { controller = "Something", action = "SomethingDelete" });
routes.MapRoute(null, "site/Something/Save", new { controller = "Something", action = "SomethingSave" });
routes.MapRoute(null, "site/Something/Add", new { controller = "Something", action = "SomethingAdd" });


更新:

我强烈建议为每个实体使用单独的控制器,路由如下:

routes.MapRoute(null, "site/{controller}/{action}");