public ActionResult Index(int pageParent)
{
var id = pageParent;
var pages = (from p in db.pages
where p.pageParent == id
select p);
PageParentModel model = new PageParentModel();
model.page = pages;
model.pageParent = id;
return View(model);
}
答案 0 :(得分:2)
像这样修改你的行动
public ActionResult Index(int? pageParent) {
// this way your pageParent parameter is marked to be nullable
// dont forget to check for the null value in code
}
答案 1 :(得分:1)
在查询字符串中未提供参数的情况下,您也可以设置默认值 - 例如:
public ActionResult Index([DefaultValue(1)] int pageParent) {
}