【发布时间】:2014-11-29 07:10:02
【问题描述】:
我正在尝试在执行多个操作的同一索引页面中重定向。
问题是在索引页面中使用 id 参数“http://example.com/Student/Index/1” Url.Action("Index") 或 Html.ActionLink("Index") 将始终生成:“http://example.com/Student/Index/1”而不是“http://example.com/Student”
这发生在菜单和面包屑上。
控制器:
public ActionResult Index(int? id)
{
if (id == null) {
// Show List
} else if (id <= 0) {
// Show Create Form
} else {
//Show Edit Form
}
}
有什么方法可以在视图上不带参数重定向到同一页面?
【问题讨论】:
标签: c# asp.net-mvc asp.net-mvc-routing