0

I need to read a web page from my asp.net app (i use C# and Framework 4.6.1), as part of a bigger application. My code in local run fine, but when i upload it on my host (Aruba shared host) and try to read https://forumcommunity.net/ I get the error " The request was aborted: Could not create SSL/TLS secure channel"..while other sites are properly read (for example google, youtube, etc). Maybe is a problem of my host.. but i don't know where to start to solve the problem.. Thanks in advance for the help.

string Uri = TextBoxLink.Text;

    ServicePointManager.Expect100Continue = true;
    ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls12 | SecurityProtocolType.Ssl3;
    ServicePointManager.ServerCertificateValidationCallback = delegate { return true; };

    try
    {
        HttpWebRequest request = (HttpWebRequest)WebRequest.Create(Uri);
        request.Method = "get";
        request.UserAgent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:74.0) Gecko/20100101 Firefox/74.0";
        HttpWebResponse response = (HttpWebResponse)request.GetResponse();
        Stream resSteam = response.GetResponseStream();
        StreamReader sr = new StreamReader(resSteam);
        TextBoxResult.Text = sr.ReadToEnd();
    }
    catch (Exception ex)
    {
        LabelError.Text = ex.Message;
    }
Enrico S.
  • 1
  • 1
  • Welcome! You can start with this popular thread on so: https://stackoverflow.com/questions/2859790/the-request-was-aborted-could-not-create-ssl-tls-secure-channel – L0uis Apr 22 '20 at 22:59
  • Actually with not much information provided closing question as duplicate of one suggested by @L0uis is the best can be done. If none of the suggestions there worked you need to [edit] question to provide all information you've collected during the validation of all answers so this question can be re-opened. – Alexei Levenkov Apr 22 '20 at 23:04

0 Answers0