我新的ASP.NET MVC和我现在面临一些结构性的设计问题。ASP.NET MVC结构设计问题
我无法弄清楚如何设置路由。
我想以下几点:
http://website/ > HomeController Action=Index Public: http://website/{controller} > SectionController Action=Index http://website/products/id > ProductsController Action=Details http://website/products/category/id > ProductsController Action=ListByCatId http://website/products/categories/ > ProductsController Action=ListCategories http://website/products/categories/id > ProductsController Action=DetailsCategories Admin: http://website/admin/ > AdminController Action=Index http://website/admin/{controller} > SectionController Action=Index
默认图路线是对大多数零件:
routes.MapRoute("Default", "{controller}/{action}/{id}", _
New With {.controller = "Home", .action = "Index", .id = ""})
当我开始把“类别”,而不是产品的问题的id开始...
如果我硬编码“的routeUrls,如“产品/分类/(编号)”?
对于管理部分:
我喜欢把属于在该网站的管理部分的所有控制器:/Controllers/Admin/XxxController.vb。是否有可能命名空间并让它们与公共区域中的名称相同? e.q.
- Website.ProductsController类公共部位和
- Website.Admin.ProductsController为管理部分?我应该如何设置?
*领域*(新的MVC 2)可以帮助您与此有关。它们提供了站点不同区域之间的清晰分隔,区域定义了路由,控制器等内容。 – bzlm 2010-01-27 11:01:02