I'm trying to redirect in same Index page that do multiple actions.
The problem is when in Index page with id parameter "http://example.com/Student/Index/1" Url.Action("Index") or Html.ActionLink("Index") will always generate : "http://example.com/Student/Index/1" instead of "http://example.com/Student"
This happen on Menu and Breadcrumb.
Controller :
public ActionResult Index(int? id)
{
if (id == null) {
// Show List
} else if (id <= 0) {
// Show Create Form
} else {
//Show Edit Form
}
}
Is there any way to redirect to same page without parameter on View?
You can set the route value to an empty string
@Html.ActionLink("Link text", "Index", new { id = "" })
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments