Does ServicePointManager.SecurityProtocol handle both http and https (encrypted web pages)?

gideon isaac 81 Reputation points
2021-03-02T22:28:11.897+00:00

I have some code that downloads files off the net. (This is to save me time, for instance if I want to read news items from a opinion-site, I can load the links I'm interested in a user-friendly way.) Those files could be web pages, or PDFs, or text.
Suppose I have a link like: americanthinker.com/thepage.htm and suppose I don't know whether the link should start with "http" or "https". The way I handle it now is that I use two routines, one of which sets ServicePointManager.SecurityProtocol to TLS12, (for https) and one that sets it to 0, (for http). So if one fails, I try the other. This has the bonus that I find out which prefix is appropriate, and I also download the file.
But I did a little reading today, and in the later versions of dot net, you don't have to set the securityProtocol at all, because the default behavior is to try everything and whatever finally works gets the download done.
So I just want to be sure on this: If I delete any servicepointManager code that I hadd been using, but I put the wrong prefix on a web page, for instance http when it should be https, (or vice versa) will it be successfully downloaded? And will there be any way to know whether https was used in the successful effort, or whether http was used? If the wrong prefix means the download is not successful, I can just try both prefixes, (without using servicemanager.securityprotocol).

VB
VB
An object-oriented programming language developed by Microsoft that is implemented on the .NET Framework. Previously known as Visual Basic .NET.
2,735 questions
{count} votes

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.