C#调用asp页面或php页面,反回页面数据方法
来源:互联网 发布:涤纶 锦纶 知乎 编辑:程序博客网 时间:2024/05/16 17:23
using System.Net;
using System.IO;
String url = "http://xxxx.net/api.php?source=test&user=6666&pass=1234&agent_user=1000&function=version";
HttpWebRequest webrequest = (HttpWebRequest)HttpWebRequest.Create(url);
HttpWebResponse webreponse = (HttpWebResponse)webrequest.GetResponse();
Stream stream = webreponse.GetResponseStream();
byte[] rsByte = new Byte[webreponse.ContentLength]; //save data in the stream
try
{
stream.Read(rsByte, 0, (int)webreponse.ContentLength);
return System.Text.Encoding.UTF8.GetString(rsByte, 0, rsByte.Length).ToString();
}
catch (Exception exp)
{
return exp.ToString();
}
using System.IO;
String url = "http://xxxx.net/api.php?source=test&user=6666&pass=1234&agent_user=1000&function=version";
HttpWebRequest webrequest = (HttpWebRequest)HttpWebRequest.Create(url);
HttpWebResponse webreponse = (HttpWebResponse)webrequest.GetResponse();
Stream stream = webreponse.GetResponseStream();
byte[] rsByte = new Byte[webreponse.ContentLength]; //save data in the stream
try
{
stream.Read(rsByte, 0, (int)webreponse.ContentLength);
return System.Text.Encoding.UTF8.GetString(rsByte, 0, rsByte.Length).ToString();
}
catch (Exception exp)
{
return exp.ToString();
}
用HttpWebRequest/HttpWebResponse 顺利得到... 感谢下面两篇博文~ T T
http://blog.csdn.net/gaoyunpeng/archive/2007/02/28/1517151.aspx
http://www.cnblogs.com/fgq841103/articles/1280664.html
- C#调用asp页面或php页面,反回页面数据方法
- JavaScript页面调用C#后台方法或访问参数
- php页面调用自定义方法
- ASP.Net 利用反射调用页面方法
- asp.net客户端脚本调用页面方法
- jquery调用asp.net 页面后台方法
- jquery调用asp.net 页面后台方法
- asp.net页面调用后台类方法
- C#后台调用前台页面js方法
- C#后台调用前台页面js方法
- php页面调用微信扫一扫
- ASP.NET 页面间数据传递方法
- ASP.NET 页面间数据传递方法
- 三。页面调用方法
- 页面调用后台方法
- php 抓取页面数据
- PHP页面包涵数据
- php调用另一php页面
- 用html5做的树
- 黑马程序员-- .Net学习日记——数据库
- 从一个jsp页面向另一个jsp页面传值
- php cURL库(抓取网页,post数据及其他)
- 用xfire客户端调用服务端时,传递参数总是null
- C#调用asp页面或php页面,反回页面数据方法
- 最近笔试总结二
- Xcode中联调静态库工程
- CString、TCHAR *、char*转换
- ERP的扫盲知识
- 提防假冒的太阳能充电软件
- 框架学习之Spring 第二节 采用Spring管理Bean和依赖注入
- STM32GPIO——快速IO的使用
- SQLserver数据库连接问题(wfa程序登录源代码)