Thursday, February 10, 2011

ASP.Net MVC Redirect To A Different View

Is it possible to redirect to a different view from a controller? For example in this case all my controllers inherit from a custom controller that has a contructer that I want to redirect to different view if certain criteria is not meet.

Hope that makes sense.

Thanks

  • You can RedirectToAction, 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.

    Gavin Draper : If I did it this way how do I return a specific view from a controller Action.
    Craig Stuntz : return View("ViewName");

0 comments:

Post a Comment