7 months ago

C# post method works on localhost but not on shared host Ask Question

Posted 7 months ago by Jason_Born

I'm testing an C# application which uses method post to get data from "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);

for myhost is http://localhost:8000/ it works, but

for myhost is https://example.com/ it doesn't (returned 405 error code).

I'm using Laravel 5.7 framework for my website, the .htaccess file is as below:

<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
    Options -MultiViews -Indexes

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]

# 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
# php -- END cPanel-generated handler, do not edit

What's causing this problem? Thanks in advance.

Please sign in or create an account to participate in this conversation.