Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
234 views
in Technique[技术] by (71.8m points)

c# - Load web browser with web response

I am working in an application that creates online accounts(Let suppose Gmail) When user run application i navigate the WebBrowser control to Url.User fill the registration form and complete the registration. It is working fine up to here. Now user want to use proxy to access that site. What I want user sets proxy in another form and when he runs application his request is automatically handled by that proxy. One solution is that I first navigate to proxy and then user enter his website and then navigate through that proxy server. But I want that user dose not see proxy server web page and only sees the desire page accessed through proxy.

I read in a post that use WebRequest class to navigate to web site and set the proxy of my
request to desire proxy and then load WebBrowser with this response. how to set WebBrowser proxy How to load Webbrowser control with response? Will this work as desired?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
 HttpWebRequest webRequest = (HttpWebRequest)WebRequest.Create("http://example.com");
 webRequest.Proxy = new WebProxy(host, port);

 HttpWebResponse response = (HttpWebResponse)webRequest.GetResponse();
 Stream receiveStream = response.GetResponseStream();

 WebBrowser webBrowser = new WebBrowser();
 webBrowser.DocumentStream = receiveStream;     

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...