私のコントローラにGET要求のみを許可したいと思い、VerbFilterを添付しました。ドキュメントでは、要求のメソッドが許可されていないときに405 httpステータスコードを返さなければならないと言いますが、代わりに500ステータスコードがあります。あなたが見ることができるようにYii2 VerbFilterは405の代わりに500のステータスコードを返します
class MyController extends Controller {
...
public function behaviors(){
return [
'verb' => [
'class' => VerbFilter::className(),
'actions' => [ '*' => ['get'] ]
];
}
public function actions(){
return [ 'error' => [
'class' => 'yii\web\ErrorAction'
]];
}
...
}
エラーメッセージ
An Error occurred while handling another error:
exception 'yii\web\MethodNotAllowedHttpException' with message
'Method Not Allowed. This url can only handle the following request methods: GET.'
in /yii_project/vendor/yiisoft/yii2/filters/VerbFilter.php:105
Previous exception:
exception 'yii\web\MethodNotAllowedHttpException' with message
'Method Not Allowed. This url can only handle the following request methods: GET.'
in /yii_project/vendor/yiisoft/yii2/filters/VerbFilter.php:105
は、&過去のエラーは、現在のエラーの複製です。私はそれの理由についてのアイデアはありません。
500 405エラーを受け取ることになりますですサーバーエラー、私はあなたがエラーがあると思います。 GETによるリクエストは正常に機能しますか? –
@Jørgenはい、GETは正常に動作します。エラーメッセージは、別のエラーを処理中にエラーを通知します。つまり、VerbFilterは2つのエラーを出します。私はVerbFilterを2回付けました。しかし、私はしません。 Wtf ... :( –
は500エラーのログを提供します –