I wrote a small app that dl youtube vids but like most company's they dont allow you to view youtube so i would like to incorporate a proxy option into my app to dl the youtube vids through a supplied proxy ip and port.
Thank you for your time.
I wrote a small app that dl youtube vids but like most company's they dont allow you to view youtube so i would like to incorporate a proxy option into my app to dl the youtube vids through a supplied proxy ip and port.
Thank you for your time.
's sample shows the right idea: set a proxy on your HTTP requests instead of trying to force the WebBrowser control. For a desktop downloader you have two practical approaches that avoid the WebBrowser control and let you stream large files safely through a proxy.
Use HttpClient for modern, streamed downloads (recommended). Configure an HttpClientHandler with a proxy, request the response with ResponseHeadersRead and copy the response stream to disk so you don't buffer the whole file in memory:
var handler = new HttpClientHandler
{
Proxy = new WebProxy("203.0.113.10", 8080),
UseProxy = true
};
using (var client = new HttpClient(handler))
using (var resp = await client.GetAsync(fileUrl, HttpCompletionOption.ResponseHeadersRead))
using (var src = await resp.Content.ReadAsStreamAsync())
using (var dst = File.Create(targetPath))
{
await src.CopyToAsync(dst);
} For very simple cases, WebClient also supports a Proxy property and will DownloadFile synchronously. Set proxy credentials if the proxy requires authentication.
A few important notes and troubleshooting tips:
References: HttpClientHandler.Proxy and WebClient.Proxy documentation, WebBrowser overview, and WinINet InternetSetOption for programmatic proxy changes.
Jump to Post— kvprajapati 1,826If your are working with asp.net web application then it is easy and fast in asp.net using httpmodule.
Read this article -
Jump to Post— sknake 1,622using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using System.Net; using System.Web; using System.IO; namespace daniweb { public partial class frmProxy : Form { public frmProxy() { InitializeComponent(); } private bool useProxy; private void button1_Click(object sender, EventArgs e) { …
If your are working with asp.net web application then it is easy and fast in asp.net using httpmodule.
Read this article - http://www.hanselman.com/blog/AnIPAddressBlockingHttpModuleForASPNETIn9Minutes.aspx
Extending ASP.NET Processing with HTTP Modules
If your are working with asp.net web application then it is easy and fast in asp.net using httpmodule.
Read this article - http://www.hanselman.com/blog/AnIPAddressBlockingHttpModuleForASPNETIn9Minutes.aspx
Extending ASP.NET Processing with HTTP Modules
This is a desktop application, I just want to learn how to implement proxy settings in my applications to give more privacy when using my apps. I read that the System.Net.WebProxy class could be the answer but im not sure anyone clarify this for me please
thank you for your post
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Net;
using System.Web;
using System.IO;
namespace daniweb
{
public partial class frmProxy : Form
{
public frmProxy()
{
InitializeComponent();
}
private bool useProxy;
private void button1_Click(object sender, EventArgs e)
{
useProxy = true;
WebProxy proxy = new WebProxy("146.57.249.99", 3124);
HttpWebRequest req = (HttpWebRequest)HttpWebRequest.Create(@"http://www.whatismyip.com");
if (useProxy)
req.Proxy = proxy;
req.Method = "GET";
HttpWebResponse objResponse = (HttpWebResponse)req.GetResponse();
string htmlStuff;
using (StreamReader sr = new StreamReader(objResponse.GetResponseStream()))
{
htmlStuff = sr.ReadToEnd();
sr.Close();
}
System.Diagnostics.Debugger.Break();
}
}
} Awesome thank you i will try and implement this with in my apps.
Thank you again
You're welcome
Please mark this thread as solved if you have found a solution to your problem and good luck!
so with that implementation above how would i download a file going through a proxy?
for testing to see if it work i was trying to use the webbrowser control i couldn't get the webbrower control to use the proxy.
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.