【HttpHelper万能框架教程】- GET请求 
 
导读部分 
 1.【HttpHelper万能框架】教程目录贴  http://www.sufeinet.com/thread-9989-1-1.html 
 
 
教程部分 
  
GET是最基本的请求,是使用Http协议进行的一次Get数据发送和接收的过程,就类似于我们在浏览器输入一个URl 
例如输入http://www.sufeinet.com 我们会打开网站 苏飞论坛 
 
而GET就是要模拟这一次请求,当然Post请求的原理也是这样的,只在这里介绍一次以后不再介绍 
 
下面看下怎么样使用我的框架来完成这一次发送和接收数据 
第一步引入命名空间 
[C#] 纯文本查看 复制代码 
using CsharpHttpHelper;
using System.Net;  
 
第二部在页面CsharpHttpHelper_Demo下写相关代码 
[C#] 纯文本查看 复制代码 using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using CsharpHttpHelper_Demo.Helper;
using CsharpHttpHelper;
using System.Net;
namespace CsharpHttpHelper_Demo
{
    public partial class HttpGet_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 = "get",//URL     可选项 默认为Get   
                ContentType = "text/html",//返回类型    可选项有默认值   
                //ContentType = "application/x-www-form-urlencoded",//返回类型    可选项有默认值   
            };
            //请求的返回值对象
            HttpResult result = http.GetHtml(item);
            //获取请请求的Html
            string html = result.Html;
            //获取请求的Cookie
            string cookie = result.Cookie;
        }
    }
} 
 
就是这么简单完成了。 
 |