核心更新:Httphelper万能框架新增异步调用方法 
 
 
 
讨论区:http://www.sufeinet.com/forum-169-1.html   
 
教程:http://httphelper.sufeinet.com/Course.aspx 
 
例子:http://httphelper.sufeinet.com/demo.aspx 
 
源码下载:http://www.sufeinet.com/thread-9926-1-1.html 
 
 
购买年费会员,终身VIP,都可直接下载源码,框架购买链接 
http://www.sufeinet.com/plugin.php?id=qmx8_buy_usergroup:vip 
 
 
使用方法如下 
    首先要引用命名空间 
[C#] 纯文本查看 复制代码 using CsharpHttpHelper.Enum;
using CsharpHttpHelper;  
 
然后以Get本站为例子代码如下 
 
[C#] 纯文本查看 复制代码             //创建Httphelper对象
            HttpHelper http = new HttpHelper();
            //创建Httphelper参数对象
            HttpItem item = new HttpItem()
            {
                URL = "http://www.sufeinet.com"//URL     必需项    
            };
            //开始异步调用
            http.BeginInvokeGetHtml(item, new ResultHandler(SetHtml)); 
 
异步调用所用的方法如下 
[C#] 纯文本查看 复制代码         /// <summary>
        /// 在异步执行完成后要回调的方法
        /// </summary>
        /// <param name="result"></param>
        public void SetHtml(HttpResult result)
        {
            //获取请请求的Html
            string html = result.Html;
            //获取请求的Cookie
            string cookie = result.Cookie;
            //状态码
            HttpStatusCode code = result.StatusCode;
            //状态描述
            string Des = result.StatusDescription;
            if (code == HttpStatusCode.OK)
            {
                //状态为200
            }
        } 
 
完整代码 
 
[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 System.Text;
using CsharpHttpHelper.Enum;
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     必需项    
            };
            //开始异步调用
            http.BeginInvokeGetHtml(item, new ResultHandler(SetHtml));
          
        }
        /// <summary>
        /// 在异步执行完成后要回调的方法
        /// </summary>
        /// <param name="result"></param>
        public void SetHtml(HttpResult result)
        {
            //获取请请求的Html
            string html = result.Html;
            //获取请求的Cookie
            string cookie = result.Cookie;
            //状态码
            HttpStatusCode code = result.StatusCode;
            //状态描述
            string Des = result.StatusDescription;
            if (code == HttpStatusCode.OK)
            {
                //状态为200
            }
        }
    }
} 
好了使用方法还是比较简单的,大家赶紧下载使用吧。 
 
 
 
 |