Redirect And Rendering

I’ve noticed that when you put a redirect in your controller, the render file is executed anyway, why is this?

I found this ‘problem’ by setting a flash message which gets deleted (Yii::$app->session->getFlash(‘success’, null, true)). When i do a redirect, the flash message never appears (because it’s getting deleted before it redirects).

Setting controller:


public function actionIndex()


        $this->redirect(array('site/index'));


        return $this->render('index', array('settings' => $settings)); // This is getting executed, despite the redirect.


}

Should i put a Yii::$app->end() or something after $this->redirect… ?

just return it, like this:

return $this->redirect(array(‘site/index’));

Off course, thanks again!