在我StudenntController我hvae的方法「{控制器}/{行動}/{ID}」 沒有通過參數
public ActionResult ClassStudents(int? classRoomId)
{
var students = st.GetAll().Where(s => s.ClassRoomID == classRoomId);
ViewBag.ClassRoomTitle = clr.GetAll().Where(c=>c.ClassRoomID == classRoomId).Single().ClassRoomTitle;
return View(students);
}
當我進入localhostxxxx /學生/ ClassStudent/1 參數classRoomId是空,我得到一個錯誤:序列不包含任何元素 我想知道爲什麼網址:「{控制器}/{行動}/{id}」不通過參數?
你是如何配置路由表的? – tia 2013-04-28 02:32:17
你能提供你的路由配置代碼嗎?如果你使用默認配置,那麼參數必須是id而不是classRoomId – 2013-04-28 02:48:34