如何加载Web浏览器的Web响应 [英] How to load web browser with web response

查看:210
本文介绍了如何加载Web浏览器的Web响应的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在创建网上帐户申请工作(我们假设的Gmail) 当用户运行的应用程序,我导航WebBrowser控件Url.User填写登记表并完成注册。 这是工作的罚款高达这里。 现在,用户要使用代理服务器来访问该网站。 我要的是另一种形式的用户设置代理,当他运行应用程序了他的请求是由代理服务器自动处理。 一个解决方案是,我第一次浏览到代理,然后用户可以输入自己的网站,然后通过代理服务器浏览。 但我想,用户量没有看到代理服务器的网页,只看到通过代理访问的愿望页。

我在报纸上看到使用的WebRequest 类导航到网站,并设置我的
代理后 请求渴望代理,然后加载web浏览器这个响应。 如何设置web浏览器的代理 如何加载Web浏览器控件与反应? 将这项工作作为期望?

解决方案

 的HttpWebRequest的WebRequest =(HttpWebRequest的)WebRequest.Create(http://example.com);
 webRequest.Proxy =新WebProxy(主机,端口);

 HttpWebResponse响应=(HttpWebResponse)webRequest.GetResponse();
 流receiveStream = response.GetResponseStream();

 web浏览器web浏览器=新的web浏览器();
 webBrowser.DocumentStream = receiveStream;
 

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?

解决方案

 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;     

这篇关于如何加载Web浏览器的Web响应的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆