how to use 'RedirectToAction' in a controller that inherits from 'RenderMvcController'?
hey out there,
hit a weird one: we've a site where each doctype has it's own controller. each controller inherits from 'RenderMvcController'.
i'm trying to call 'RedirectToAction' to move from one controller to another and it's failing with a 'No route in the route table matches the supplied values.' ysod.
this is the set up for controller one:
public class BasketController : RenderMvcController
{
[HttpGet]
public ActionResult Index(BasketViewModel model)
{
var viewModel = ViewModelFactory.Create<BasketViewModel>(model.Content);
return CurrentTemplate(viewModel);
}
}
and this is controller two, the one were i'm trying to redirect back to controller one:
public class CheckoutController : RenderMvcController
{
[HttpGet]
public ActionResult Index(BasketViewModel model)
{
var viewModel = ViewModelFactory.Create<CheckoutViewModel>(model.Content);
if (viewModel.Basket.TotalItemQuantity == 0) return RedirectToAction("Index", "Basket", new {area = ""});
return CurrentTemplate(viewModel);
}
}
i've seen a couple of suggestions online to do 'return Redirect("~/basket");' which seems clunky and i'm not a big fan of the url being hardcoded?
is 'RedirectToAction' possible in the way i'm trying?
how to use 'RedirectToAction' in a controller that inherits from 'RenderMvcController'?
hey out there,
hit a weird one: we've a site where each doctype has it's own controller. each controller inherits from 'RenderMvcController'.
i'm trying to call 'RedirectToAction' to move from one controller to another and it's failing with a 'No route in the route table matches the supplied values.' ysod.
this is the set up for controller one:
and this is controller two, the one were i'm trying to redirect back to controller one:
i've seen a couple of suggestions online to do 'return Redirect("~/basket");' which seems clunky and i'm not a big fan of the url being hardcoded?
is 'RedirectToAction' possible in the way i'm trying?
any suggestions would be grand!
cheers,
jake
AFAIK umbraco uses its own routing which will break the route table for RedirectToAction().
It is maybe that there is no catch all {controller}/{action} route? but I'm not familiar with the core...
This article seems to have info aboput registering routes without breaking the Umbraco routing. http://shazwazza.com/post/custom-mvc-routes-within-the-umbraco-pipeline/
Or - if the checkout page exists in Umbraco can you not do something like
Thanks
Carl
is working on a reply...