I've looked through google, and I saw things like WebRequest, WebProxy, etc. There were a lot of pages, but I don't get it. So let's say I have a TextBox with the URL in it, and another TextBox with the proxy in it. How would I make it so that I could use a proxy on the URL?
Asked
Active
Viewed 912 times
2 Answers
0
One option would be to create a request using the HttpWebRequest object detailed here:
http://msdn.microsoft.com/en-us/library/system.net.httpwebrequest.aspx
One of the properties of the HttpWebRequest object is 'Proxy':
http://msdn.microsoft.com/en-us/library/system.net.httpwebrequest.proxy.aspx
A good implementation example can be found here:
problem using proxy with HttpWebRequest in C#
-
I don't understand how to use any of those. Whenever I try to use them, it always errors, or doesn't work at all. – Minicl55 Jun 23 '12 at 04:57
-
Why does it give you errors? Can you provide more info/details? – ems305 Jun 23 '12 at 05:22
-
It usually doesn't work. I set up a simple HTML site with a site counter, and the only time it went up was when I tested it with my browser. Sometimes it tells me something about a URI, but I think I'm just using it wrong. – Minicl55 Jun 26 '12 at 05:35
0
You could use RestSharp's Rest Client (https://www.nuget.org/packages/RestSharp) to pull data, and then render in a WebBrowser object:
try {
var response = new RestClient {
BaseUrl = "https://theproxisright.com/",
Proxy = new WebProxy("1.2.3.4", 8080),
Timeout = 10000
}.Execute(new RestRequest {
Resource = "api/Proxy/Get?apiKey=ENTER_FREE_OR_UNLIMITED_API_KEY_HERE",
Method = Method.GET,
});
if (response.ErrorException != null) {
throw response.ErrorException;
} else {
Console.WriteLine(response.Content);
var wb = new WebBrowser{ Width = 200 };
webBrowserStack.Children.Add(wb);
wb.NavigateToString(response.Content);
}
} catch (Exception ex) {
Console.Error.WriteLine(ex.Message);
}

sobelito
- 1,525
- 17
- 13