开发者

MVC3 RedirectToAction after postback

开发者 https://www.devze.com 2023-04-03 16:42 出处:网络
With MVC, I hear that it\'s good practice to get back to a \'GET\' action by using RedirectToAction after processing the Http postback. I understand this is so the postback is not repeated should the

With MVC, I hear that it's good practice to get back to a 'GET' action by using RedirectToAction after processing the Http postback. I understand this is so the postback is not repeated should the user refresh the page or bookmark and revisit it. I think that is sensible but after开发者_开发技巧 the redirect the model errors are lost so I can't display them using Html.ValidationSummary. What is the recommended practice in this scenario? Many thanks


You shouldn't allow to redirect before errors are displayed. In fact, all logic happens before redirect - insert new data, check data, display errors, correct data, save data, redirect, insert new data.

0

精彩评论

暂无评论...
验证码 换一张
取 消