I have been looking through trying to find some way to redirect to an Index view from another controller.
public ActionResult Index()
{
try:
public ActionResult Index() {
return RedirectToAction("actionName");
// or
return RedirectToAction("actionName", "controllerName");
// or
return RedirectToAction("actionName", "controllerName", new {/* routeValues, for example: */ id = 5 });
}
and in .cshtml view:
@Html.ActionLink("linkText","actionName")
OR:
@Html.ActionLink("linkText","actionName","controllerName")
OR:
@Html.ActionLink("linkText", "actionName", "controllerName",
new { /* routeValues forexample: id = 6 or leave blank or use null */ },
new { /* htmlAttributes forexample: @class = "my-class" or leave blank or use null */ })
Notice using null in final expression is not recommended, and is better to use a blank new {} instead of null