Exemplo n.º 1
0
        private void btnAsyncGet_Click(object sender, EventArgs e)
        {
            HttpHelpers http = new HttpHelpers();                                        //请求发起对象
            HttpItems   item = new HttpItems();                                          //请求设置对象

            System.Net.CookieContainer cc = new System.Net.CookieContainer();            //自动处理cookie对象
            item.URL       = "bbs.msdn5.com";                                            //请求地址
            item.Container = cc;                                                         //初始化cookie
            item.Timeout   = 3 * 5000;
            Action <HttpResults> ActionCallback = new Action <HttpResults>(GetCallBack); //完成后的回调地址

            http.AsyncGetHtml(item, ActionCallback);                                     //执行异步请求,结果在ActionCallback的回调函数(GetCallBack)中查看
        }
Exemplo n.º 2
0
        private void btnAsyncPost_Click(object sender, EventArgs e)
        {
            string PostD = string.Format("{0}", txtVcode.Text);

            item.URL        = PostUrl;
            item.Referer    = BaseUrl;
            item.Method     = "Post";
            item.IsAjax     = true;
            item.ResultType = ResultType.String;
            item.Postdata   = PostD;
            item.Container  = cc;
            Action <HttpResults> ActionCallback = new Action <HttpResults>(Post_AsyncCallBack);

            http.AsyncGetHtml(item, ActionCallback);
        }