Usually you redirect only after successful publication (without model validation errors), otherwise you send a page with a validation error message.
MvcContrib template redirection project code: ModelStateToTempDataAttribute
This was also mentioned along with other tips in the article "Best Practices" on weblogs.asp.net (the author seems to have moved the blog, but I could not find the article on the new blog). From the article:
One of the problems with this pattern is that the check fails or any exception occurs, you need to copy ModelState to TempData. if you do it manually, please stop it, you can do it automatically with action filters, for example:
controller
[AcceptVerbs(HttpVerbs.Get), OutputCache(CacheProfile = "Dashboard"), StoryListFilter, ImportModelStateFromTempData] public ActionResult Dashboard(string userName, StoryListTab tab, OrderBy orderBy, int? page) {
Action filters
public abstract class ModelStateTempDataTransfer : ActionFilterAttribute { protected static readonly string Key = typeof(ModelStateTempDataTransfer).FullName; } public class ExportModelStateToTempData : ModelStateTempDataTransfer { public override void OnActionExecuted(ActionExecutedContext filterContext) {
source share