ASP.Net MVC Redirect To A Different View

Gavin picture Gavin · Feb 13, 2009 · Viewed 216.4k times · Source

Is it possible to redirect to a different view from a controller?

For example, all my controllers inherit from a custom controller that has a constructor that I want to redirect to different view if certain criteria is not met. Hope that makes sense.

Answer

John Sheehan picture John Sheehan · Feb 13, 2009

You can use the RedirectToAction() method, then the action you redirect to can return a View. The easiest way to do this is:

return RedirectToAction("Index", model);

Then in your Index method, return the view you want.