jeudi 7 janvier 2016

System.Net.WebException when using Webclient and Proxy

public string Webpost(string paramm)
    {
        string result;
        using (WebClient client = new WebClient())
        {
            WebProxy wp = new WebProxy();
            wp.Address = new Uri("http://ift.tt/1mEjH0h");
            wp.UseDefaultCredentials = false;
            wp.BypassProxyOnLocal = false;
            client.Proxy = wp;
            client.Headers[HttpRequestHeader.ContentType] = "application/x-www-form-urlencoded";
            result = client.UploadString("http://amazon.com", paramm);
        }

        return result;

    }

I end up with System.Net.WebException when running the above code using proxy. Commenting (client.Proxy = wp;) that is running the code without proxy works fine. What could be wrong?




Aucun commentaire:

Enregistrer un commentaire