【HttpHelper万能框架教程】- POST请求
导读部分
1.【HttpHelper万能框架】教程目录贴 http://www.sufeinet.com/thread-9989-1-1.html
教程部分
POST请请求是使用Http协议与请求的URL进行连接,然后再写入数据,最后关闭连接的过程。
下面看下怎么样使用我的框架来完成这一次发送和接收数据第一步引入命名空间
[C#] 纯文本查看 复制代码
using CsharpHttpHelper;
using System.Net;
第二部在页面下写相关代码
[C#] 纯文本查看 复制代码 using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using CsharpHttpHelper;
using System.Net;
using CsharpHttpHelper.Enum;
namespace CsharpHttpHelper_Demo
{
public partial class HttpPost_Demo : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
//创建Httphelper对象
HttpHelper http = new HttpHelper();
//创建Httphelper参数对象
HttpItem item = new HttpItem()
{
URL = "http://www.sufeinet.com",//URL 必需项
Method = "post",//URL 可选项 默认为Get
ContentType = "application/x-www-form-urlencoded",//返回类型 可选项有默认值
Postdata = "a=123&c=456&d=789",//Post要发送的数据
};
//请求的返回值对象
HttpResult result = http.GetHtml(item);
//获取请请求的Html
string html = result.Html;
//获取请求的Cookie
string cookie = result.Cookie;
}
}
}
就是这么简单完成了。
|