2010-08-05 27 views
0

我有行動SomethingEditor,SomethingDelete,SomethingSave,SomethingAdd,我想設定這些路由:網站/事/編輯,網站/事/刪除,網站/事/保存等問題有關ASP.NET MVC路由

如何我能行?

回答

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" }); 


UPDATE:

我強烈建議使用下面的合成路線的每個實體一個單獨的控制器:

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

嘛。我可以只添加前綴[某事]行動嗎?如果我有很多行動,那就很難。 – Neir0 2010-08-05 14:04:18

+0

不是開箱即用。 Tt可能是一個自定義的httphandler,但我強烈建議爲每個實體使用一個單獨的控制器。 – Fabian 2010-08-05 14:41:30