.net - 在 Controller 中创建子文件夹

标签 .net asp.net-mvc

如何在ASP.NET MVC 1中进行操作,以获取子文件夹。例如,在 Controller 上采用以下文件夹结构:

/Controller
  /Blog
     ViewsController.cs
     ArticlesController.cs
  /Customers
     SalesController.cs
     ProductsController.cs
  HomeController.cs

我想在 View 中使用以下文件夹结构,每个 View 都找到了您的 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

最佳答案

您可以使用路线来实现,即

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

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

关于.net - 在 Controller 中创建子文件夹,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1748960/

相关文章:

c# - 高性能的属性访问和可能的动态编译

c# - 删除 ListView 中的列数据

c# - 是否可以将在 .net core 上运行的 Identity Server 4 与在 .net 4.5.1 上运行的 WebApi 应用程序一起使用?

asp.net-mvc - ASP.NET MVC : FileStreamResult returning too many bytes?

asp.net-mvc - ASP.NET MVC - 在子目录中运行

c# - 您应该在 ASP.NET MVC 的 global.asax 中使用 Application_Error 方法吗?

.net - 为什么我的 boolean 值 0 返回 true?

asp.net-mvc - 如何在没有页面构建器的情况下在 Kentico 12 中使用 BizForms

css - 将 mvc 元素部署到 Win server 2008 r2 后,IE 9 border-radius 不起作用

c# - 列出 CHM 文件中的所有主题