I want to create a subfolder for my controllers.
This is my folder structure:

What is the best way to get the below result?
localhost/home
Controller: Common/Home
View: Common/Home
localhost/product
Controller: Catalog/Product
View: Catalog/Product
I want to create a subfolder for my controllers.
This is my folder structure:

What is the best way to get the below result?
localhost/home
Controller: Common/Home
View: Common/Home
localhost/product
Controller: Catalog/Product
View: Catalog/Product
In asp.net MVC Controllers, folders are ignored, as long as the cs files are set to compile they will be compiled into the DLL file and referenced by taking the class name (i.e ProductController) and dropping the word Controller from the end.
So the folder structure is largely up to yourself for whatever makes sense for your own project management.
If you are trying to get certain URLs to direct to certain controllers have a look at Routing instead.
Use routes.MapRoute for routing see below example:
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapRoute(
"Blog", // Route name
"Archive/{entryDate}", // URL with parameters
new { controller = "Archive", action = "Entry" } // Parameter defaults
);
routes.MapRoute(
"Default", // Route name
"{controller}/{action}/{id}", // URL with parameters
new { controller = "Home", action = "Index", id = "" } // Parameter defaults
);
}