【发布时间】:2019-07-29 11:17:44
【问题描述】:
我正在测试一个 C# 应用程序,它使用 post 方法从“myhost/post_test”获取数据:
var client = new WebClient();
var data = new NameValueCollection();
data["email"] = email_input.Text;
data["password"] = pw_input.Text;
ServicePointManager.Expect100Continue = true;
ServicePointManager.SecurityProtocol = ServicePointManager.SecurityProtocol
= SecurityProtocolType.Tls
| SecurityProtocolType.Tls11
| SecurityProtocolType.Tls12
| SecurityProtocolType.Ssl3;
var response = client.UploadValues("myhost/post_test", "POST", data);
对于 myhost 是 http://localhost:8000/ 它可以工作,但是
对于 myhost 是 https://example.com/ 它不是(返回 405 错误代码 - 不允许使用方法)。
我的网站使用的是 Laravel 5.7 框架,.htaccess 文件如下:
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews -Indexes
</IfModule>
RewriteEngine On
# Handle Authorization Header
RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
# Redirect Trailing Slashes If Not A Folder...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} (.+)/$
RewriteRule ^ %1 [L,R=301]
# Handle Authorization Header
RewriteCond %{HTTPS} !=on
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>
# php -- BEGIN cPanel-generated handler, do not edit
# Set the “alt-php72” package as the default “PHP” programming language.
<IfModule mime_module>
AddHandler application/x-httpd-alt-php72___lsphp .php .php7 .phtml
</IfModule>
# php -- END cPanel-generated handler, do not edit
是什么导致了这个问题?提前致谢。
编辑 1:我将把我使用的路线放在这里:
Route::group(['prefix'=>'client_server_protocol'],function(){
Route::group(['prefix'=>'version19'],function(){
Route::post('login','AppController@postLogin');
Route::post('AuthCheck','AppController@postAuthCheck');
Route::post('ask_hrs_to_auth_check','AppController@postAsk_hrs_to_auth_check');
});
});
在“登录”Route::post 失败
【问题讨论】:
-
Laravel 中的 405 错误表示路由不存在。确保你已经在 Laravel 中设置了路由。
-
其他路线都运行良好,不可能只有这条路线吧?
-
405 通常意味着路由是使用与您发出请求不同的方法定义的。您可以发布您的路线文件吗?
-
我的帖子更新了,请看一下
标签: c# laravel cpanel shared-hosting