Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ASP.Net MVC: Rewriting with routing

I want to map the following URI:

/admin/controller/action/id

to the following:

Controller -> Controller
Action     -> Admin_Action

For example:

/admin/Users/Create

Controller -> Users
Action  -> Admin_Create

/admin/Users/Delete/1

Controller -> Users
Action -> Admin_Delete(1)

Can I achieve that using routing rules?

like image 832
Timo Willemsen Avatar asked Feb 23 '23 18:02

Timo Willemsen


1 Answers

I think the following route mapping should work ...

 routes.MapRoute("YourRouteName", "admin/controller/action/{id}", new { controller = "Controller", action = "Admin_Action", id = UrlParameter.Optional });
like image 59
brodie Avatar answered Mar 03 '23 17:03

brodie