When I used httpwebrequest to access other websites, the error "the request was aborted: unable to establish SSL/TLS Secure Channel" appeared. So goog and Baidu compared the problem. The answer is servicepointmanager. servercertificatevalidationcallback write delegate
Public responsemodel gethtml (string URL) {servicepointmanager. servercertificatevalidationcallback = validateservercertificate; httpwebrequest request = (httpwebrequest) webrequest. create (URL);} private bool validateservercertificate (Object sender, x509certificate certificate, x509chain chain, sslpolicyerrors) {return true ;}
However, this method does not work for me. The error still persists.
The final solution is to execute the statement servicepointmanager. securityprotocol = securityprotocoltype. ssl3; before accessing the URL.
Public responsemodel gethtml (string URL) {servicepointmanager. securityprotocol = securityprotocoltype. ssl3; httpwebrequest request = (httpwebrequest) webrequest. Create (URL );}
The whole world is much quieter. Haha