简体   繁体   English

如何下载网页资源并在webbrowser中显示?

[英]How to download a webpage source and show in webbrowser?

So I wanted to know if there is a way to download a webpage's source code and then show it in a webbrowser. 因此,我想知道是否可以下载网页的源代码,然后将其显示在网络浏览器中。

My main problem is user is going to use a web proxy in my application and sometimes these proxies have username and password but I don't want the user to always input his/her own password for the browser so I thought that I make a webclient request and set proxy and user/pass for it then download the source of the requested page and then show it in the webbrowser but if you know a way to for example give the webbrowser username and password please let me know. 我的主要问题是用户将在我的应用程序中使用Web代理,有时这些代理具有用户名和密码,但我不希望用户始终为浏览器输入自己的密码,所以我认为我是一个Web客户端请求并为其设置代理和用户/密码,然后下载所请求页面的源,然后在Web浏览器中显示它,但是如果您知道例如提供Web浏览器用户名和密码的方法,请告诉我。

thanks. 谢谢。

use 采用

WebClient.downloadString();

msdn msdn

But I suggest that you display the source in a good Editor like Notepad++ instead of a WebBrowser. 但是,我建议您使用诸如Notepad ++之类的优质编辑器而不是WebBrowser来显示源。

Edit: I don't know about passing username and passwort for the proxy though. 编辑:我不知道通过代理的用户名和密码。

Edit2: webClient.Credentials = new System.Net.NetworkCredential("UserName", "Password", "Domain"); Edit2: webClient.Credentials = new System.Net.NetworkCredential("UserName", "Password", "Domain");

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM