开发者

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 respons开发者_如何学运维e? Will this work as desired?


 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;     
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜