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。接受第一個 –