如何设置代理和发送Https帖子 [英] How Do I Set Proxy And Send Https Post

查看:104
本文介绍了如何设置代理和发送Https帖子的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好

当我将此代码用于设置代理和发送帖子

我的项目变得挂起而没有响应

为什么? PLZ帮助我,编辑我的代码



Hello
When I use this code for set proxy and Send Post
My Project became hang and not responding
why? plz help me, and edit my code

public static string HttpPost(string URI, string Parameters)
     {
        string ResP = "";

        WebProxy Prxy = new WebProxy(ProxyString, true;

             System.Net.WebRequest req = System.Net.WebRequest.Create(URI);

             Application.DoEvents();
           req.Proxy = Prxy;

             req.ContentType = "application/x-www-form-urlencoded";
             req.Method = "POST";

             byte[] bytes = System.Text.Encoding.ASCII.GetBytes(Parameters);
             req.ContentLength = bytes.Length;
             Application.DoEvents();
             System.IO.Stream os = req.GetRequestStream();
             os.Write(bytes, 0, bytes.Length);
             os.Close();
             Application.DoEvents();
             System.Net.WebResponse resp = req.GetResponse();

             System.IO.StreamReader sr = new System.IO.StreamReader(resp.GetResponseStream());


            ResP = sr.ReadToEnd().Trim();


        return ResP;

     }

推荐答案

也许有帮助,我正在使用WebClient



MyWebClient clientWithProxy = new MyWebClient();

WebProxy(123.123.123.123,8080);

clientWithProxy.Proxy = proxy;



string result = clientWithProxy.DownloadString(http://www.google.com);
Maybe it helps, I'm using WebClient

MyWebClient clientWithProxy = new MyWebClient();
WebProxy("123.123.123.123",8080);
clientWithProxy.Proxy = proxy;

string result = clientWithProxy.DownloadString("http://www.google.com");


您好



可能是以下链接对您有用。





http://stackoverflow.com/questions / 1372519 / how-to-use-http-post-with-proxy-support-in-c-sharp [ ^ ]


这篇关于如何设置代理和发送Https帖子的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆