【发布时间】:2015-04-22 19:50:04
【问题描述】:
我将 2 个可为空的参数传递给 Products 操作。但是我不得不在mallId 中传递一些值,否则我会收到no route table matches found 错误。我想在mallId 中传递null 并在Products 操作中接收。
return RedirectToRoute("Products",
new
{
mallId =(Int32?)null,
storeId =(Int32?)storeProducts.StoreId
});
[Route("Mall/{mallId?}/Store/{storeId?}/Products", Name = "Products")]
public ActionResult Products(string mallId, long? storeId)
{
return View(products);
}
属性路由让我头疼,但它也很棒。
【问题讨论】:
标签: c# asp.net-mvc-5 attributerouting