How can I do in ASP.NET MVC 1, to take sub folders. For example, taking the following folder structure on the controller:
/Controller
/Blog
ViewsController.cs
ArticlesController.cs
/Customers
SalesController.cs
ProductsController.cs
HomeController.cs
I would like to have the following folder structure in view, each view found your controller:
/Views
/Blog
/Views
Index.aspx
Admin.aspx
Show.aspx
/Articles
Show.aspx
Admin.aspx
/Customers
/Sales
Index.aspx
Totals.aspx
/Products
Index.aspx
Promotions.aspx
/Home
Index.aspx
This is a feature that has been added in ASP.NET MVC 2.0. It is called Areas.
You could do it using Routes, i.e.
routes.MapAreaRoute("Blogs",
"Blog/Views/{controller}/{action}/{id}",
new { controller = "Views", action = "Index", id = "" });
That would seem to meet your needs given the data above.
In MVC 2 or higher, you just need to right click on the project, then mouse over add, then click Area, and enter in the name of the area. Everything is automatically created for you!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With