S
S
Sergey Pugovkin2017-03-27 12:57:48
Yii
Sergey Pugovkin, 2017-03-27 12:57:48

In beforeAction , the NotFoundHttpException is displayed as an error, not a 404 page. Why?

In beforeAction , the NotFoundHttpException is displayed as an error, not a 404 page. Why?
How to display normally?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexey Likhachev, 2017-03-28
@Driver86

Are you sure you are throwing exceptions? The code below works great and returns 404

<?php

namespace backend\controllers;

use Yii;
use yii\web\Controller;
use yii\web\NotFoundHttpException;

class SiteController extends Controller
{

    public function beforeAction($action)
    {
        throw new NotFoundHttpException();
    }

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question