Could Not create ssl/tls secure channel. Html Agility

c# html-agility-pack web-scraping

Question

I am trying to scrape a site using HTML Agility Pack. The site is using https and it shows the error on this line

doc = web.Load(url);

I am creating a desktop application not a web application.

Popular Answer

You need to enable the correct protocol type on the service point manager. Just add it before the line you said caused the error. This should do it.

ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
doc = web.Load(url);


Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Is this KB legal? Yes, learn why
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Is this KB legal? Yes, learn why