问题
I'm running windows 7 and IE9. I'm writing a winforms application (.net 4.0 & c#) that runs a proxy server (using TcpListener) on another thread.
Before I instantiate the main form i set the proxy using InternetSetOption and start the proxy server.
My proxy setting code is very similar to the one here: Set Proxy UserName and Password using Wininet in C#
then i browse to a site in IE, IE doesn't connect to my proxy server. also, IE tools --> internet options --> connection --> lan settings --> use a proxy server for your LAN checkbox is NOT checked. but when I run fiddler, this checkbox IS checked. this means fiddler is setting the proxy correctly, but I'm not. how does fiddler do that? i have gone thru' numerous blogs, MSDN articles on InternetSetOption in vain. any help is appreciated.
My proxy server code is very similar to the one here: Simple Http proxy using Sockets: Questions
I know my proxy server works because, when I go to IE tools --> internet options --> connection --> lan settings and explicitly set the proxy server to 127.0.0.1:9898 (thats where I run my proxy server), IE and all other browsers connect to my server.
回答1:
The WinINET.cs file in this code download: http://code.msdn.microsoft.com/CSWebBrowserWithProxy-c8535715 has the core functionality to set the WinINET proxy. It gets a few minor details slightly wrong, but will work properly for most cases.
来源:https://stackoverflow.com/questions/12011276/unable-to-set-wininet-proxy-from-winforms-application