Alex Rivera | Logout

When do you use View() vs. RedirectToAction

Asked 2011-04-25T06:12:29.797
23

This existing question sums up the basics of my question. The best answers there tells the difference between the two methods. I am looking for guidelines as to which method to use.

In short, I have an action in a controller which process a form and then display the results of the processing. When should I use return View() as opposed to return RedirectToAction("FormResult")?

Edit
Report

1 Answer

10

You can really use either. Generally speaking, though, after a form is posted you want to redirect so that refreshing the page doesn't cause the form to repost. Sometimes, however, it's not feasible to copy state to the new page and your processing is idempotent so refresh wouldn't hurt anything.

It's not that there's a hard-and-fast rule. You kind of have to weigh the pros and the cons.

answered 2011-04-25T06:17:33.983

Your Answer