Custom MVC Route: Change Location for the Controller

So, I have a controller called EmployeeController, and all views are in / Employee.

I would like to create a route so that the EmployeeController uses / Employees and / Employees / Add instead of / Employee and / Employee / Add.

I continue to find articles on how to change the route in order to proceed to various actions, but I could not find a way to do this.

+3
source share
3 answers

I think you are confusing Route Views. ASP.NET MVC relies heavily on convention, and in this example, the route controller component uses it to find the controller. You can define a new route:

routes.MapRoute("Employees", "employees/{action}", new { 
    controller = "Employee",
    action = "Index" });
+2
source

, :

  • , , 13.
  • "" . - , ViewResult View. , IViewEngine .

, , , - URL, employees/{action}, .

+1

EmployeeController EmployeesController? .

, Views\Employee Views\Employees.

0
source

Source: https://habr.com/ru/post/1783693/


All Articles