This question is about the latest DNN platform release: DNN 8.0.1. I am trying to redirect to an action in my controller-classes, but I am not able to do it.
For example the following check:
// Check if user is voting on his own item
if (item.CreatedByUserId == User.UserID)
return RedirectToAction("Index");
This is the error I receive when the controller tries to return an action. DotNetNuke.Services.Exceptions.ModuleLoadException: No route in the route table matches the supplied values. ---> System.InvalidOperationException: No route in the route table matches the supplied values.
I don't know how routing is working in DNN (MVC) and I couldn't find anything helpful about is.
Thank you!
DNN's routing is different from MVCs because it has to untangle different modules. You could create a method in your controller to override the default method in this way:
public new ActionResult RedirectToAction(string actionName, string controllerName, object routeValues)
{
var routeVals = TypeHelper.ObjectToDictionary(routeValues);
routeVals["controller"] = controllerName;
routeVals["action"] = actionName;
return Redirect(ModuleRoutingProvider.Instance().GenerateUrl(routeVals, ModuleContext));
}