请求https接口的时候提示基础连接已经关闭:连接被意外关闭

我把做好的.net项目部署到IIS上,项目中有POST请求别人的https接口,然后就提示:
基础连接已经关闭:连接被意外关闭,搞了一天了,都不知道怎么解决,望大神来拯救我把

private static bool CheckValidationResult(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors errors)
    {
        return true; //总是接受
    }


    public string PostWebRequest(string postUrl, string paramData, Encoding dataEncode)
    {
        // ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback(CheckValidationResult);


        //  System.Net.ServicePointManager.CertificatePolicy = new TrustAllCertificatePolicy();
        //utilHelper utilHelper = new DAL.utilHelper();
        //utilHelper.SetCertificatePolicy();
        string ret = string.Empty;
        try
        {
            byte[] byteArray = dataEncode.GetBytes(paramData); //转化
            HttpWebRequest webReq = (HttpWebRequest)WebRequest.Create(postUrl);
            if (postUrl.StartsWith("https", StringComparison.OrdinalIgnoreCase))
            {
                ServicePointManager.ServerCertificateValidationCallback =
                        new RemoteCertificateValidationCallback(CheckValidationResult);
            }
            webReq.KeepAlive = false;
            //webReq.ProtocolVersion = HttpVersion.Version11;
            webReq.Method = "POST";
            webReq.Timeout = 1000000;
            System.Net.ServicePointManager.Expect100Continue = false;
            //  webReq.KeepAlive = false;
            webReq.ContentType = "application/json";// "application/json";//application/x-www-form-urlencoded
            //   ServicePointManager.ServerCertificateValidationCallback = CheckValidationResult;
            //if (postUrl.StartsWith("https", StringComparison.OrdinalIgnoreCase))
            //{
            //    logger.Error("设置了");

            //   // webReq.ProtocolVersion = HttpVersion.Version10;
            //}
            webReq.ContentLength = byteArray.Length;
            Stream newStream = webReq.GetRequestStream();
            newStream.Write(byteArray, 0, byteArray.Length);//写入参数
            // newStream.Close();
            HttpWebResponse response = (HttpWebResponse)webReq.GetResponse();
            StreamReader sr = new StreamReader(response.GetResponseStream(), dataEncode);
            ret = sr.ReadToEnd();
            sr.Close();
            response.Close();
            newStream.Close();
        }
        catch (Exception ex)
        {
            logger.Error("POST异常:" + ex.Message);
        }
        return ret;
    }


            这是我的post请求代码,谁能救救我……

这个https请求可以访问到吗?用浏览器console请求试试

将超时设置的稍微大一些试试看

楼主是想在自己的服务器去请求另一个服务器是么

一般这个问题就这几个方面:
1.可能的referer跟cookie,这2个可能对方服务器也许要检查
不过你说本地没问题就先跳过
2.参数问题,抓包看看自己的请求跟浏览器是否一致
我这里是说记录发布后的请求数据
3.get请求可以不设置contenttype和useragent,但是post一般都需要,楼主没有加上
4。ProtocolVersion = HttpVersion.Version10; //这个好像以前看周公文章说过,可以避免https请求报错,具体忘记了,最好加上

感觉不是超时的问题,可能是权限的问题

public string PostWebRequest(string postUrl, string paramData, Encoding dataEncode)
{
string ret = string.Empty;
try
{
byte[] byteArray = dataEncode.GetBytes(paramData); //转化
HttpWebRequest webReq = (HttpWebRequest)WebRequest.Create(postUrl);
if (postUrl.StartsWith("https", StringComparison.OrdinalIgnoreCase))
{
ServicePointManager.ServerCertificateValidationCallback =
new RemoteCertificateValidationCallback(CheckValidationResult);
}
webReq.KeepAlive = false;
webReq.ProtocolVersion = HttpVersion.Version10;
//webReq.ProtocolVersion = HttpVersion.Version11;
webReq.Method = "POST";
webReq.Timeout = 1000000;
// ServicePointManager.CheckCertificateRevocationList = true;
webReq.UserAgent = "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2; .NET CLR 4.0.30319;)";
webReq.ContentType = "application/json";// "application/json";//application/x-www-form-urlencoded
webReq.ContentLength = byteArray.Length;
Stream newStream = webReq.GetRequestStream();
newStream.Write(byteArray, 0, byteArray.Length);//写入参数

            HttpWebResponse response = (HttpWebResponse)webReq.GetResponse();
            StreamReader sr = new StreamReader(response.GetResponseStream(), dataEncode);
            ret = sr.ReadToEnd();
            sr.Close();
            response.Close();
            newStream.Close();
            webReq.Abort();

        }
        catch (Exception ex)
        {
            logger.Error("POST异常:" + ex.Message);
        }

        return ret;
    }