C# webclient and proxy server -
I am using a web client class in my source code to download a string using HTTP.
It was working fine, however, all the customers of the company are now connected to the proxy server and the problem started with this.
When I have tested my application, I do not think this proxy can pass through the server, because the exception is throwing "no response from xxx.xxx.xxx .xxx which is the proxy server ip The address is.
However, I can still navigate to the web site URL and when it connects through a proxy server correctly displays the string in the browser, but when I use my sub Does not the web client.
Is there anything in the web client to allow me to access the URL behind a proxy server?
By using (Webclick WC = New WebClient ()) {string strURL =. Download "http: // xxxxxxxxxxxxxxxxxxxxxxxx"; // only if webclient is not busy (wc.IsBusy) {string rtn_msg = string.Empty; try {rtn_msg = wc} .DownloadString (new url (strURL)); return rtn_msg;} hold (WebExchange pre) {Console.Write (ex.Message); Details are false;; hold (Exception pre) {Console.Write (ex.Message); the description is false;}} and {System.Windows.Forms.MessageBox.Show ("busy please try again"); return false; }}
My solution:
WebClient Client = New webclient (); WebProxy WP = new WebProxy ("Proxy server URL here"); Client.Proxy = wp; String str = client.DownloadString ("http://www.google.com");
Comments
Post a Comment