Redirection issue

Hi, guys. Looks like i need some GURU :D

I need override ErrorAction (i dont want see default error template. i want error in popup.) for that purpose i’m using TOASTR. It was working before today. It just stoped work. Adunno why.

inside SiteController

public function actions()


        return [

            'error' => [

                'class' => 'common\overrides\web\ErrorAction',




and common\overrides\web\ErrorAction


namespace common\overrides\web;

use Yii;

use yii\base\Exception;

use yii\base\UserException;

use yii\helpers\Url;

class ErrorAction extends \yii\web\ErrorAction


    public function run()


        if (($exception = Yii::$app->getErrorHandler()->exception) === null) {

            // action has been invoked not from error handler, but by direct route, so we display '404 Not Found'

            $exception = new HttpException(404, Yii::t('yii', 'Page not found.'));


        if ($exception instanceof HttpException) {

            $code = $exception->statusCode;

        } else {

            $code = $exception->getCode();


        if ($exception instanceof Exception) {

            $name = $exception->getName();

        } else {

            $name = $this->defaultName ?: Yii::t('yii', 'Error');


        if ($code) {

            $name .= " (#$code)";


        if ($exception instanceof UserException) {

            $message = $exception->getMessage();

        } else {

            $message = $this->defaultMessage ?: Yii::t('yii', 'An internal server error occurred.');


        if (Yii::$app->getRequest()->getIsAjax()) {

            return "$name: $message";

        } else {

            Yii::$app->getSession()->setFlash('error', $message);


            return $this->controller->redirect(Url::toRoute(['/site/dashboard']));




i debugged and sure that php reaches #POINT (look at comment in code) but redirect does nothing

up. still have no solution. please, help :)

What happens if you try to redirect using header() function in PHP?

Header not working in any point of app.

return $this->redirect(*);

not working only in error action (i mean i can use it in test action and all works fine)