protected virtual void Redirect(IRedirectSupport redirecter, string area, string controller, string action, IDictionary parameters) { if (UseRouting) { redirecter.RedirectUsingRoute(area, controller, action, parameters); } else { redirecter.Redirect(area, controller, action, parameters); } }
/// <summary> /// Performs a strongly typed redirect to an action of the <typeparamref name="TController"/>. /// <para /> /// This must be a lamda in the form of <c>c => c.Action(optional, action, parameters)</c>, /// where the action parameters can be anything you want (variable, property, method call etc.) /// as long as they return the right parameter and the lambda function will compile. /// </summary> /// <typeparam name="TController">The type of the controller that has the action.</typeparam> /// <param name="self">The object that supports redirecting.</param> /// <param name="useRouting">If true, uses routing.</param> /// <param name="action">An expression that respresents the redirect in the form of a lambda function call.</param> public static void Redirect <TController>( this IRedirectSupport self, bool useRouting, Expression <Action <TController> > action) where TController : IController { AssertArguments(self, action); ActionMethodModel model = CreateModel(action); var redirecter = new ResponseRedirectInvoker { UseRouting = useRouting }; redirecter.Redirect(self, model); }
protected override void Redirect(IRedirectSupport redirecter, string area, string controller, string action, IDictionary parameters) { if (UseRouting) { base.Redirect(redirecter, area, controller, action, parameters); } else { if (redirecter != _controller) { throw new TypedActionException( "The controller and the redirecter must be the same instance, but they are not. " + "Controller = {0} and redirecter = {1}.", _controller, redirecter); } _controller.RedirectToAction(action, parameters); } }
public virtual void Redirect(IRedirectSupport redirecter, ActionMethodModel action) { Redirect(redirecter, action.Area, action.Controller, action.Action, action.GetParameterDictionary()); }
public static void Redirect <TController>( this IRedirectSupport self, Expression <Action <TController> > action) where TController : IController { Redirect(self, DefaultUseRouting, action); }