创建控制器的子文件夹 [英] Create sub folders in the controller
本文介绍了创建控制器的子文件夹的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我怎么能做到在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
解决方案
您可以使用路由做到这一点,即
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.
这篇关于创建控制器的子文件夹的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文