1
我将2个可为空的参数传递给一个Products动作。但是我被迫在mallId
中传递一些值,否则我得到一个no route table matches found
错误。我想在mallId
中通过null
并在Products
行动中收到。传递两个可选参数到RedirectToRoute
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);
}
属性路由正在破解我的头,但它也很棒。
这两个答案都适用。 Upvoted.Thanks。接受第一个 –