创建控制器的子文件夹控制器、文件夹

2023-09-04 02:08:42 作者:Sensational 煽情

我怎么能做到在ASP.NET MVC 1,取子文件夹。例如,采取控制器上下面的文件夹结构:

  /控制器
  /博客
     ViewsController.cs
     ArticlesController.cs
  /客户
     SalesController.cs
     ProductsController.cs
  HomeController.cs
 

我想有鉴于以下文件夹结构,每个视图发现控制器:

  /浏览次数
  /博客
     /浏览次数
        的Index.aspx
        Admin.aspx
        Show.aspx
     /文章
        Show.aspx
        Admin.aspx
  /客户
     /销售
        的Index.aspx
        Totals.aspx
     /产品
        的Index.aspx
        Promotions.aspx
  /家
     的Index.aspx
 

解决方案 解决无法访问Windows 2003域控制器中共享文件夹

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

  routes.MapAreaRoute(博客,
        博客/浏览/ {控制器} / {行动} / {ID},
        新{控制器=意见,行动=索引,ID =});
 

这似乎能满足您的需求上面给出的数据。

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

解决方案

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.