Neir0
Neir0

Reputation: 13367

Question about ASP.NET MVC routing

I have actions SomethingEditor, SomethingDelete, SomethingSave, SomethingAdd and i want set these routing: site/Something/Editor, site/Something/Delete, site/Something/Save etc

How i can do it?

Upvotes: 0

Views: 53

Answers (1)

Fabian
Fabian

Reputation: 13691

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

Upvotes: 1

Related Questions