如何在c#中创建我的http请求代理?

时间:2014-08-17 21:41:59

标签: c# proxy

当我使用下面的代码时,我收到此错误:ServicePointManager不支持使用https方案的代理。

如何更改此代码以使其代理?

        var request = (HttpWebRequest) WebRequest.Create("https://website.com/index.php?");
        var myproxy = new WebProxy("https:/website.com/index.php?");

        request.Proxy = myproxy;
        string postData = "Secret=" +textBox1.text;
        byte[] data = Encoding.ASCII.GetBytes(postData);

        request.Method = "POST";

        request.ContentType = "application/x-www-form-urlencoded";
        request.ContentLength = data.Length;

        using (Stream stream = request.GetRequestStream())
        {
            stream.Write(data, 0, data.Length);
        }

        var response = (HttpWebResponse) request.GetResponse();

        string read = new StreamReader(response.GetResponseStream()).ReadToEnd();


        response.Close();

0 个答案:

没有答案