In .NET 4.8/CMS 11.x and earlier, this is very commonly used to redirect an action
return RedirectToAction("Index", new{ node = contentLink });
Which will redirect the user to
public TResult Index(CheckoutPage currentPage );
and you will get the currentPage
parameter set with content you specified by the contentLink
.
However in .NET 5 once redirected currentPage will be null. It’s due to how .NET 5 handle the routing. The correct way is use this
return RedirectToContent(currentPage.ContentLink, "Index");
There is a action you can use – RedirectToContent
. Note that the order of parameter is reserved – you pass in the content link to the content first, then the name of the action.
And that’s how’s it done in .NET 5/CMS 12.
Hi, thanks for the post. There is no overload that accepts route values, like the old one. How would you use RedirectToContent without having to manually construct the URL? See forum post here: https://world.optimizely.com/forum/developer-forum/cms-12/thread-container/2022/12/redirect-to-another-action-method-on-same-pagecontroller-throwing-error-no-route-matches-the-supplied-values/