在维护接口的时候,本地代码调用https接口返回基础连接已经关闭,发送时发生错误。搞了两天没明白为什么会返回错误,接口方说他们那边也没有限制。postman客户端也是可以调通的,但是后来发现网页版的postman调不通,后来查了好久发现是兼容性问题,但是这接口在别的服务器上跑的好好的,不知道为什么会突然发生兼容性问题。所以给贴出来大家参考
//添加https兼容处理
HttpWebRequest request = null;
if (url.StartsWith("https", StringComparison.OrdinalIgnoreCase))
{
ServicePointManager.SecurityProtocol = (SecurityProtocolType)3072;
request = WebRequest.Create(url) as HttpWebRequest;
}
else
{
request = (HttpWebRequest)WebRequest.Create(url);
}
————————————————
原文链接:https://blog.csdn.net/Elvis_lq/article/details/124325581