手机
当前位置:查字典教程网 >编程开发 >asp.net教程 >dz asp.net论坛中函数--根据Url获得源文件内容
dz asp.net论坛中函数--根据Url获得源文件内容
摘要:需要引入命名空间:复制代码代码如下:usingSystem.Net;usingSystem.IO;函数内容:复制代码代码如下://////根...

需要引入命名空间:

复制代码 代码如下:

using System.Net;

using System.IO;

函数内容:

复制代码 代码如下:

/// <summary>

/// 根据Url获得源文件内容

/// </summary>

/// <param name="url">合法的Url地址</param>

/// <returns></returns>

public static string GetSourceTextByUrl(string url)

{

WebRequest request = WebRequest.Create(url);

request.Timeout = 20000;//20秒超时

WebResponse response = request.GetResponse();

Stream resStream = response.GetResponseStream();

StreamReader sr = new StreamReader(resStream);

return sr.ReadToEnd();

}

【dz asp.net论坛中函数--根据Url获得源文件内容】相关文章:

运行asp.net时出现 http错误404-文件或目录未找到

asp.net(c#)中取得文件物理路径

asp.net小孔子cms中的数据添加修改

asp.net生成高质量缩略图通用函数(c#代码),支持多种生成方式

asp.net Xml绑定到数据控件的具体实现

asp.net2.0如何加密数据库联接字符串

asp.net下大文件上传知识整理

在ASP.net中保存/取出图片入/从SQL数据库

asp.net下经典数据库记录分页代码

asp.net字符串分割函数使用方法分享

精品推荐
分类导航