• C# http请求


            /// <summary>
            /// GET方式发送得结果
            /// </summary>
            /// <param name="url">请求的url</param>
            public static string DoGetRequestSendData(string url)
            {
                HttpWebRequest hwRequest = null;
                HttpWebResponse hwResponse = null;

                string strResult = string.Empty;
                try
                {
                    hwRequest = (System.Net.HttpWebRequest)WebRequest.Create(url);
                    //hwRequest.Timeout = 30000;
                    hwRequest.Method = "GET";
                    hwRequest.ContentType = "application/x-www-form-urlencoded";
                }
                catch (System.Exception err)
                {

                }
                try
                {
                    hwResponse = (HttpWebResponse)hwRequest.GetResponse();
                    StreamReader srReader = new StreamReader(hwResponse.GetResponseStream(), Encoding.ASCII);
                    strResult = srReader.ReadToEnd();
                    srReader.Close();
                    hwResponse.Close();
                }
                catch (System.Exception err)
                {
                }
                return strResult;
            }

  • 相关阅读:
    2012年浙大:Hello World for U
    noip2011普及组:统计单词
    noip2013提高组:积木大赛
    蓝桥杯:错误票据
    C#知识点
    疑问
    C#多态
    SQLServer导入Excel,复杂操作
    SQLServer数据库基本操作,导入Excel数据
    C#基础学习
  • 原文地址:https://www.cnblogs.com/jincieryi/p/9630054.html
Copyright © 2020-2023  润新知