When do you use View() vs. RedirectToAction

后端 未结 3 602
心在旅途
心在旅途 2021-02-18 14:38

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

3条回答
  •  清歌不尽
    2021-02-18 15:14

    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.

提交回复
热议问题