获取ashx得到的内容(已处理好的数据)

内容摘要
要获取一个ashx页面的到的数据,使用以下方法: 1. 复制代码 代码如下: WebClient wc = new WebClient(); Byte[] pageData = wc.DownloadData("http://xxxx.com"); hd_num.Valu
文章正文
要获取一个ashx页面的到的数据,使用以下方法:
1.
复制代码 代码如下:

WebClient wc = new WebClient();
Byte[] pageData = wc.DownloadData("http://xxxx.com");
hd_num.Value = Encoding.Default.GetString(pageData);
前台代码:<asp:HiddenField ID="hd_num" runat="server" />
再通过js获取hd_num的值。

2.
复制代码 代码如下:

HttpWebRequest request = HttpWebRequest.Create("http://xxx/aaa.ashx") as HttpWebRequest;
HttpWebResponse response = request.GetResponse() as HttpWebResponse;
Stream resStream = response.GetResponseStream();
StreamReader sr = new StreamReader(resStream, System.Text.Encoding.Default); //编码可以改成别的
ContentHtml.Text = sr.ReadToEnd();

3.
还可以用ajax的跨域请求,这部分还在研究中,不知咋弄。
主要我那个ashx页面传过来的就是已经处理好的数据。
代码注释

作者:喵哥笔记

IDC笔记

学的不仅是技术,更是梦想!