How to get filter to redirect to another action?

RedirectToAction is just a helper method to construct a RedirectToRouteResult(), so what you do is simply create a new RedirectToRouteResult() passing along a RouteValueDictionary() with values for your action. Complete sample based on code from @Domenic in the comment below: public class IsGuestAttribute: ActionFilterAttribute { public override void OnActionExecuting(ActionExecutingContext filterContext) { if (!Ctx.User.IsGuest) { filterContext.Result … Read more

ASP.NET MVC – How to Preserve ModelState Errors Across RedirectToAction?

I had to solve this problem today myself, and came across this question. Some of the answers are useful (using TempData), but don’t really answer the question at hand. The best advice I found was on this blog post: http://www.jefclaes.be/2012/06/persisting-model-state-when-using-prg.html Basically, use TempData to save and restore the ModelState object. However, it’s a lot cleaner … Read more