Skip to content

Commit

Permalink
Merge pull request #2171 from ahoefling/mvc-redirect
Browse files Browse the repository at this point in the history
Adds support for RedirectToAction from a DnnController
  • Loading branch information
ohine authored Jul 18, 2018
2 parents a6bc0bf + 723a311 commit 400727f
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
using System.Web.Mvc;
using System.Web.Routing;
using DotNetNuke.Common;
using DotNetNuke.Web.Mvc.Framework.Controllers;
using DotNetNuke.Web.Mvc.Helpers;

namespace DotNetNuke.Web.Mvc.Framework.ActionResults
{
Expand All @@ -34,6 +36,14 @@ public DnnRedirecttoRouteResult(string actionName, string controllerName, string
ControllerName = controllerName;
}

public DnnRedirecttoRouteResult(string actionName, string controllerName, string routeName, RouteValueDictionary routeValues, bool permanent, DnnUrlHelper url)
: this(actionName, controllerName, routeName, routeValues, permanent)
{
Url = url;
}

public DnnUrlHelper Url { get; private set; }

public string ActionName { get; private set; }

public string ControllerName { get; private set; }
Expand All @@ -45,8 +55,15 @@ public override void ExecuteResult(ControllerContext context)
Guard.Against(context.IsChildAction, "Cannot Redirect In Child Action");

string url;
//TODO - match other actions
url = Globals.NavigateURL();
if (Url != null && context.Controller is IDnnController)
{
url = Url.Action(ActionName, ControllerName);
}
else
{
//TODO - match other actions
url = Globals.NavigateURL();
}

if (Permanent)
{
Expand All @@ -61,3 +78,4 @@ public override void ExecuteResult(ControllerContext context)
}
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,11 @@ public PortalSettings PortalSettings
get { return (ModuleContext == null) ? null : ModuleContext.PortalSettings; }
}

protected override RedirectToRouteResult RedirectToAction(string actionName, string controllerName, RouteValueDictionary routeValues)
{
return new DnnRedirecttoRouteResult(actionName, controllerName, string.Empty, routeValues, false, Url);
}

protected internal RedirectToRouteResult RedirectToDefaultRoute()
{
return new DnnRedirecttoRouteResult(String.Empty, String.Empty, String.Empty, null, false);
Expand Down

0 comments on commit 400727f

Please sign in to comment.