为了账号安全,请及时绑定邮箱和手机立即绑定

异步调用接口为什么没有弹出数据来?

异步调用接口为什么没有弹出数据来?

C#
尼古拉斯凯奇狗蛋 2016-11-08 17:51:46
     string url = string.Format("http://www.csdn.net");            HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);            request.Method = "psot";            request.Accept = "*/*";            request.UserAgent = "Mozilla/5.0";            request.ContentType = "application/x-www-form-urlencoded";            request.KeepAlive = false;            using (Stream stream = request.GetRequestStream())            {                string sendMsg = string.Empty;                byte[] buffer = new byte[url.Length];                stream.BeginWrite(buffer, 0, buffer.Length, new AsyncCallback(SearchBeginWrite), stream);            }            request.BeginGetResponse(new AsyncCallback(SearchBeginResponse), request);        }        //异步发送请求回调函数        private void SearchBeginWrite(IAsyncResult writeResult)        {            Stream stream = (Stream)writeResult.AsyncState;            stream.EndWrite(writeResult);            stream.Close();        }        private void SearchBeginResponse(IAsyncResult ResponseResult)        {            HttpWebRequest request = (HttpWebRequest)ResponseResult.AsyncState;            HttpWebResponse response = (HttpWebResponse)request.EndGetResponse(ResponseResult);            Stream stream = response.GetResponseStream();            StreamReader sr = new StreamReader(stream);            string msg = sr.ReadToEnd();            JObject jo = JObject.Parse(msg);            string[] values = jo.Properties().Select(item => item.Value.ToString()).ToArray();求问这个异步调用接口的代码哪里错了,为什么没有数据弹窗啊?我调试的时候每行代码都有走啊
查看完整描述

1 回答

?
习惯受伤

TA贡献885条经验 获得超1144个赞

用事件去做
查看完整回答
反对 回复 2016-12-23
  • 1 回答
  • 0 关注
  • 1157 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信