开发者

Question about ASP.NET MVC routing

开发者 https://www.devze.com 2023-01-10 20:45 出处:网络
I have actions SomethingEditor, SomethingDelete, Som开发者_如何学CethingSave, SomethingAdd and i want set these routing: site/Something/Editor, site/Something/Delete, site/Something/Save etc

I have actions SomethingEditor, SomethingDelete, Som开发者_如何学CethingSave, SomethingAdd and i want set these routing: site/Something/Editor, site/Something/Delete, site/Something/Save etc

How i can do it?


Using the following routes:

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:

I strongly recommend using a seperate controller for each entity with the following route:

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

精彩评论

暂无评论...
验证码 换一张
取 消