asp.net-mvc RedirectToRouteResult


Example

public ActionResult PopulateFoods()
{
    // Redirects to another action method. In this case the index method
    return RedirectToAction("Index");
}

Action methods typically return a result that is known as an action result. The ActionResult class is the base class for all action results. The ActionInvoker decideы which type of action result to return based on the task that the action method is performing.

It is possible be explicit about what type to return, but generally it not necessary.

public RedirectToRouteResult PopulateFoods()
{        
   // Redirects to another action method. In this case the index method
   return RedirectToAction("Index");
}

In case you want to redirect to another action with parameter - you can use RedirectToAction overload:

public ActionResult SomeActionWithParameterFromThisController(string parameterName)
{
   // Some logic
}
.....................
.....................
.....................
return RedirectToAction("SomeActionWithParameterFromThisController", new { parameterName = parameter });