How to redirect to Index from another controller?

cjohnson2136 picture cjohnson2136 · Oct 25, 2011 · Viewed 307.1k times · Source

I have been looking through trying to find some way to redirect to an Index view from another controller.

public ActionResult Index()
{                
     ApplicationController viewModel = new ApplicationController();
     return RedirectToAction("Index", viewModel);
}

This is what I tried right now. Now the code I was given to has a ActionLink that links to the page I need to Redirect too.

@Html.ActionLink("Bally Applications","../Application")

Answer

musefan picture musefan · Oct 25, 2011

Use the overloads that take the controller name too...

return RedirectToAction("Index", "MyController");

and

@Html.ActionLink("Link Name","Index", "MyController", null, null)