I have a folder crated in my application called admin inside the controllers, so my folder structure looks like this
-Models
|
-Views
|
-Controller
|
|-HomeController.cs
|
|-Admin
|
|-HomeController.cs <-- in this controller, i have methods Add,Delete,View
i needed to created a route so if i type the url http://localhost:2336/admin/add, it will execute the add method of the home controller, but i get a 404 error.
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapRoute(
name: "Admin",
url: "Admin/{controller}/{action}/{id}",
defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional },
namespaces: new[] { "fms.Controllers.Admin" }
);
routes.MapRoute(
"Default", // Route name
"{controller}/{action}/{id}", // URL with parameters
new { controller = "Home", action = "Index", id = UrlParameter.Optional } // Parameter defaults
);
}