【发布时间】:2011-02-15 17:05:26
【问题描述】:
我正在建立一个站点,并且正在考虑使用区域来涵盖与我将要描述的场景类似的场景。
我目前有一个包含 4 个部分的站点,我们将它们称为 Create、Manage、Section 3 和 Section 4
创建和管理是对我正在使用的域对象的操作。域对象有许多与其相关的子对象集合。这些也需要创建和管理。
我以产品为例,以免泄露任何东西,但它不太适合同一个域 - 所以请不要说“你为什么没有产品部分”
我当前的实现有一个 ManageController,它具有类别、类别、ProductsForCategory 等操作
我想我需要区域,但是,一些 URL 需要限定范围,所以我想要
- /Manage/Category/8/Products
- /Manage/Category/8/Product/1
这可以使用区域吗?我需要设置新的路由规则吗?
我的 CategoryController 是否会在操作上有 2 个参数,例如
public ActionResult Product(int categoryId, int productId)
{
//get category
var cat = GetCategory(categoryId);
//get product
var product = cat.Products.SingleOrDefault(x=>x.Id == productId);
if(product == null)
return RedirectToAction("Index","Manage");
return View(product);
}
那我会有一个在类别 id 中传递的路由规则?
我的想法对吗?
【问题讨论】:
标签: asp.net-mvc-3 asp.net-mvc-routing asp.net-mvc-areas