我爱Aspx >> Asp.Net >> 利用WebClient和WebRequest类获得网页源代码/// </summary>
private void InitializeComponent()
{
this.WebClientButton.Click += new System.EventHandler(this.WebClientButton_Click);
this.WebRequestButton.Click += new System.EventHandler(this.WebRequestButton_Click);
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
private void WebClientButton_Click(object sender, System.EventArgs e)
{
PageUrl = UrlText.Text;
WebClient wc = new WebClient();
wc.Credentials = CredentialCache.DefaultCredentials;
///方法一:
Byte[] pageData = wc.DownloadData(PageUrl);
ContentHtml.Text = Encoding.Default.GetString(pageData);
/// 方法二:
/// ***************代码开始**********
/// Stream resStream = wc.OpenRead(PageUrl);
/// StreamReader sr = new StreamReader(resStream,System.Text.Encoding.Default);
Ҷƪл˵?
使用ASP.NET中调用WebService时不..[05-20]
利用SOAP(Webservice)上传文件[05-20]
用ASP编程控制在IIS建立Web站点[05-20]
web.config文件详解[05-20]
ASP.NET:Email Web Page[05-20]
在asp.net2.0中用WebPart代替Pla..[05-20]
用C#写一个Web自定义控件[05-20]
用C#写一个Web自定义控件[05-20]
Ajax: 一个建立Web应用的新途径[05-20]
设置WEB(INTERNET)打印页眉页脚为..[05-20]
通过ASP.NET远程杀死进程[05-20]
Asp.net中DataGrid控件的自定义分..[05-20]
使用ASP.NET中调用WebService时不..[05-20]
在系统菜单中添加自定义菜单项[05-20]
利用SOAP(Webservice)上传文件[05-20]
利用ASP.NET实现域名查询[05-20]
网页防刷新重复提交、防后退解决..[05-20]
IE经典故障大全[05-20]
用ASP的方法动态写出JavaScript的..[05-20]
JavaScript 更改网页中字体大小,..[05-20]