在控制器中创建子文件夹

and*_*lzo 10 .net asp.net-mvc

如何在ASP.NET MVC 1中执行子文件夹.例如,在控制器上采用以下文件夹结构:

/Controller
  /Blog
     ViewsController.cs
     ArticlesController.cs
  /Customers
     SalesController.cs
     ProductsController.cs
  HomeController.cs
Run Code Online (Sandbox Code Playgroud)

我想在视图中有以下文件夹结构,每个视图找到你的控制器:

/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
Run Code Online (Sandbox Code Playgroud)

Dar*_*rov 8

这是ASP.NET MVC 2.0中添加的一项功能.它被称为区域.


Laz*_*rus 4

你可以使用路由来做到这一点,即

routes.MapAreaRoute("Blogs", 
        "Blog/Views/{controller}/{action}/{id}", 
        new { controller = "Views", action = "Index", id = "" });
Run Code Online (Sandbox Code Playgroud)

鉴于上述数据,这似乎可以满足您的需求。