|  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public async Task<string> AsyncRequest() | 
|---|
|  |  |  | { | 
|---|
|  |  |  | HttpWebRequest httpRequest = WebRequest.Create(Url) as HttpWebRequest; | 
|---|
|  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return responseText; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /// <summary> | 
|---|
|  |  |  | /// 异步Get | 
|---|
|  |  |  | /// </summary> | 
|---|
|  |  |  | /// <returns></returns> | 
|---|
|  |  |  | public async Task<string> AsyncGetRequest() | 
|---|
|  |  |  | { | 
|---|
|  |  |  | HttpWebRequest httpRequest = WebRequest.Create(Url) as HttpWebRequest; | 
|---|
|  |  |  | httpRequest.Method = "GET"; | 
|---|
|  |  |  | httpRequest.ContentType = "application/json"; | 
|---|
|  |  |  | httpRequest.CookieContainer = Cookie; | 
|---|
|  |  |  | httpRequest.Timeout = 1000 * 60 * 10;//10min | 
|---|
|  |  |  |  | 
|---|
|  |  |  | using (Stream reqStream = await httpRequest.GetRequestStreamAsync()) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | JObject jObj = new JObject(); | 
|---|
|  |  |  | jObj.Add("format", 1); | 
|---|
|  |  |  | jObj.Add("useragent", "ApiClient"); | 
|---|
|  |  |  | jObj.Add("rid", Guid.NewGuid().ToString().GetHashCode().ToString()); | 
|---|
|  |  |  | jObj.Add("parameters", Content); | 
|---|
|  |  |  | jObj.Add("timestamp", DateTime.Now); | 
|---|
|  |  |  | jObj.Add("v", "1.0"); | 
|---|
|  |  |  | string content = jObj.ToString(); | 
|---|
|  |  |  | var bytes = Encoding.UTF8.GetBytes(content); | 
|---|
|  |  |  | reqStream.Write(bytes, 0, bytes.Length); | 
|---|
|  |  |  | reqStream.Flush(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | using (var repStream = (await httpRequest.GetResponseAsync()).GetResponseStream()) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | using (var reader = new StreamReader(repStream)) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | return ValidateResult(await reader.ReadToEndAsync()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|