I tried to use the asp.net mvc area function. I encountered the problem of not being able to route after adding the route feature. After trying, I found that the following problems need to be paid attention to:
-
- After adding an area to the project, adding RouteArea to the controller will conflict, and the corresponding area must be removed. (If it is just to add a first-level route to the upper level of the controller, you can remove the area and declare it directly with RouteArea on the controller); the
last access address as shown in the figure below is: .../api/operation/check
- After adding an area to the project, adding RouteArea to the controller will conflict, and the corresponding area must be removed. (If it is just to add a first-level route to the upper level of the controller, you can remove the area and declare it directly with RouteArea on the controller); the
2. To use the route function, you need to add a configuration during route registration, routes.MapMvcAttributeRoutes();
3. After the RoutePrefix is declared on the controller, the action under the controller must declare Route, otherwise it cannot be accessed;