How do I redirect within a ViewResult or ActionResult function?
Posted
by Pete
on Stack Overflow
See other posts from Stack Overflow
or by Pete
Published on 2010-03-29T14:08:27Z
Indexed on
2010/03/29
14:13 UTC
Read the original article
Hit count: 694
asp.net-mvc
Say I have:
public ViewResult List() {}
inside this function, I check if there is only one item in the list, if there is I'd like to redirect straight to the controller that handles the list item, otherwise I want to display the List View.
How do I do this? Simply adding a RedirectToAction doesn't work - the call is hit but VS just steps over it and tries to return the View at the bottom.
© Stack Overflow or respective owner