Method Not Allowed (#405) Method Not Allowed. This url can only handle the following request methods
来源:互联网 发布:日本浴衣短款淘宝 编辑:程序博客网 时间:2024/05/29 14:28
在使用Yii时候出现如下情况,
在模板页面使用<a href="<?= Url::toRoute('site/logout');?>">退出后台</a>
解析后网页生成的代码的URL地址是 localhost/yii2/backend/index.php?r=site/logout,地址是对的,访问的时候出现如下:Method Not Allowed (#405) Method Not Allowed. This url can only handle the following request methods: POST. The above error occurred while the Web server was processing your request. Please contact us if you think this is a server error. Thank you.
请问为啥会出现405?哪里配置错了?配置文件里面没有配置路由
通过firebug发现前台的是可以的,而且是POST提交。而通过url生成的访问就不对了?求助
已采纳
肯定是配置site/logout
这个action的verbs了,提示很明显,这个action只接受通过POST发送的请求!
所以你检查下siteController 下的behaviors 是不是配置了
'verb' => [ 'class' => VerbFilter::className(), 'actions' => [ 'logout' => ['post'], ],],
如果允许GET访问的话,那么可以改成:
'verb' => [ 'class' => VerbFilter::className(), 'actions' => [ 'logout' => ['get'], //当然可以是是 ['get', 'post'],同时支持POST和GET两种方式访问 ],],或者<form action="?r=site/logout" method="post"> <input type="hidden" name="_csrf-frontend" value="<?php echo yii::$app->request->csrfToken?>"> <input type="submit" value="退出"> </form>
阅读全文
0 0
- Method Not Allowed (#405) Method Not Allowed. This url can only handle the following request methods
- 405 Method Not Allowed
- 405 Method Not Allowed
- 405 (Method Not Allowed)
- 405 Method Not Allowed
- Method Not Allowed 405
- Method Not Allowed / The requested method POST is not allowed for the URL
- iis 405 Method Not Allowed
- HTTP 405Method not allowed
- webapi 405 method not allowed
- post 405 method not allowed
- Method not allowed
- Method Not Allowed
- SVN报MKCOL request for ... 405 Method Not Allowed错误
- Spring MVC Json 405 (Method Not Allowed)/ 404 Bad Request
- HTTP 405 错误--Method not allowed
- HTTP错误405-Method Not Allowed
- 405 delete method not allowed 解决方案
- 第九天总结
- Yii2.0表单提交与后台接收
- hdu_6095_思维题_贪心题
- tf.control_dependencies()
- C++文件操作
- Method Not Allowed (#405) Method Not Allowed. This url can only handle the following request methods
- Python爬取百度贴吧数据
- Number Steps
- (POJ
- C++常见字符串操作函数的实现(strcpy/strcat/strcmp/strlen/strchr/strstr/strpbrk/strrev等)
- C/C++面试常考关键字
- unity profiler深入学习1:android调试配置
- ios-同步异步、进程和线程
- [SDUT](2141)数据结构实验之图论一:基于邻接矩阵的广度优先搜索遍历 ---BFS(图)