none
Unable to post data to php file under https site using WebClient RRS feed

  • Question

  • I have been using WebClient to post data to a php file. I had moved my site from http to https, just after that the WebClient's 'uploadvalues' function started reporting 404 - Not Found error.

    my server is a linux server, i access it via cpanel and proxy is used to connect to it. i am using proxy :xxx.xxx.xxx.xxx:80, i have tried removing ':80' from the proxy server string value.

    Please reply asap as its very urgent as its a problem relating to our production server and client application.

    Thanks a lot in advance.

    Tuesday, January 15, 2019 5:08 AM

All replies

  • One would think that you would have a SSL certificate on the client machine if this is a desktop solution making contact with a SSL site.

    Or is it that you think that you can start arbitrarily using HTTPS? 

    Tuesday, January 15, 2019 6:47 AM
  • yes, i have a ssl certificate and i can access the site with browsers easily using https , even the file in consideration is accesible via browsers but not via webclient. 
    Tuesday, January 15, 2019 9:53 AM
  • http://www.jarloo.com/webclient-with-certificate-support/

    Are you doing something similar?

    Tuesday, January 15, 2019 10:24 AM
  • my url is: https://htcs.co.in

    i am trying to upload a file to .php file using c# WebClient something like https://htcs.co.in/xxxxx.php

    it was working fine before with http, once i swtiched to https, it started returning error 404

    Tuesday, January 15, 2019 11:36 AM
  • my url is: https://htcs.co.in

    i am trying to upload a file to .php file using c# WebClient something like https://htcs.co.in/xxxxx.php

    it was working fine before with http, once i swtiched to https, it started returning error 404


    Show the code... So you switched to HTTPS trying to upload something to a site that's using SSL,  and maybe,  Webclient needs to present the certificate, becuase the possibility is that it could get the HTTP 404 not found for the site itself due to the certificate not being presented. And browsers are HTTPS compliant and this program using Webclient is not compliant.  
    Tuesday, January 15, 2019 11:48 AM
  • thanks a lot for your help. here is the code:

        client.Proxy = new WebProxy(global_variables.proxyserver);
                    
                    System.Collections.Specialized.NameValueCollection reqparm = new System.Collections.Specialized.NameValueCollection();
                    reqparm.Add("serial", serial_text.Text.Trim());
                    string status;

                    try
                    {
                        byte[] responsebytes = client.UploadValues("https://htcs.co.in/countonline/reactivator.php", "POST", reqparm);
                        string responsebody = Encoding.UTF8.GetString(responsebytes);
                        status = responsebody;
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show("Error communicating with activation server. Please make sure you are connected to the internet:"+ex.ToString());
                        return;
                    }


    Tuesday, January 15, 2019 12:00 PM
  • the link and filename are real, so you can directly check for anything else. any alphanumeric string can be posed as 'serial' and it should  return some integer value.
    Tuesday, January 15, 2019 12:03 PM
  • You are not using Webclient(). You are using Webproxy().

    Hopefully, your answer is in the link that makes since that HTTPS is on TCP port 443.

    https://www.dreamincode.net/forums/topic/126716-webproxy-to-access-https/

    https://www.router-switch.com/faq/difference-between-https-port-443-and-8443.html

    Tuesday, January 15, 2019 1:01 PM
  • hi, looks like i am a step closer for the solution with your help.

    After using port 443, the not found error disappeared and a new error message is showed:

    'the connection was closed unexpectedly'

    Now what could i be doing wrong?

    Thanks.

    Tuesday, January 15, 2019 1:35 PM
  • you'll have to put a try/catch on the code and get the inner.exemption meesgae if there. 
    Tuesday, January 15, 2019 3:35 PM
  • i checked inner.exeption, its null.

    Tuesday, January 15, 2019 4:39 PM
  • Hi Devbrat,

    Thank you for posting here.

    According to your issue, I create a simple console application to test it, it works when I delete the following code .

       >>client.Proxy = new WebProxy(global_variables.proxyserver);

    I suggest that you check if the proxy’s parameter is correct.

    You could also copy the url to the browser directly to confirm if it has some problems with proxy.

    Hope my advice could be helpful.

    Best regards,

    Jack


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Wednesday, January 16, 2019 9:16 AM
    Moderator