Skip to content

Adds support for RedirectToAction from a DnnController #2171

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 18, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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