Redirect to new page in controller

I’m creating a controller and if a condition is set I want to redirect the user to a new page in XP. How do I do that?

Normally you would return a “body”. But in this case you would return a “redirect”.

return {
    redirect: execute('portal.pageUrl', {
        path: pageContent._path,
        params: {
            submitted: contentCreated ? 'ok' : null

Return body:

    return {
        body: execute('thymeleaf.render', {
            view: view,
            model: model
        contentType: 'text/html'