Answer the question
In order to leave comments, you need to log in
YII2: Why does $this-redirect return an empty page?
The problem is not in the syntax, since I get the same result even with return $this->goHome();
Well, I tried a bunch of options from Google - the result is the same.
Why can this happen?
Answer the question
In order to leave comments, you need to log in
I solved the problem.
This behavior (displaying a blank page) is due to the fact that YII2 checks for the presence of a header before redirecting. If there is a header, then the redirect is not performed and an empty page will be returned.
In my case, the reason for the presence of the header was empty lines at the end in the controller file, it was worth removing them and everything worked.
1. Where do you use the redirect? In the controller I hope?
2. Make sure $this->redirect is preceded by return
2. Try this
return $this->redirect(Yii::$app->request->referrer);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question