示例#1
0
        /// <summary>
        /// 同步方式发起http post请求
        /// </summary>
        /// <param name="url">请求URL</param>
        /// <param name="queryString">参数字符串</param>
        /// <param name="errorMsg">返回错误信息.</param>
        /// <param name="headers">需要传输的Header信息.</param>
        /// <param name="encode">编码格式.</param>
        /// <returns>
        /// 请求返回值
        /// </returns>
        /// <remarks>
        ///   <list>
        ///    <item><description>添加Headers参数 modifyby Shaipe 2018/9/25</description></item>
        ///   </list>
        /// </remarks>
        public static string HttpPost(string url, string queryString, out string errorMsg, NameValueCollection headers = null, string encode = "UTF-8")
        {
            errorMsg = string.Empty;

            string referer = "";

            //if (HttpContext.Current != null && HttpContext.Current.Request != null)
            //{
            //    referer = HttpContext.Current.Request.Url.AbsoluteUri;
            //}

            NetResponse response = new NetRequest().Post(url, queryString, referer, out errorMsg);

            return(response.Content);
        }