by

Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • Oct 12 2016 22:33
    dreanor unlabeled #66
  • Oct 12 2016 22:33
    dreanor unlabeled #30
  • Oct 12 2016 22:33
    dreanor unlabeled #6
  • Oct 12 2016 22:33
    dreanor unlabeled #5
  • Oct 12 2016 22:33
    dreanor unlabeled #3
  • Oct 12 2016 22:33
    dreanor closed #77
  • Oct 12 2016 22:33
    dreanor closed #76
  • Oct 12 2016 22:33
    dreanor closed #65
  • Oct 12 2016 22:33
    dreanor closed #63
  • Oct 12 2016 22:33
    dreanor closed #30
  • Oct 12 2016 22:33
    dreanor closed #60
  • Oct 12 2016 22:33
    dreanor closed #75
  • Oct 12 2016 22:33
    dreanor closed #66
  • Oct 12 2016 22:33
    dreanor closed #73
  • Oct 12 2016 22:33
    dreanor closed #74
  • Oct 12 2016 22:33
    dreanor closed #18
  • Oct 12 2016 22:33
    dreanor closed #72
  • Oct 12 2016 22:33
    dreanor closed #15
  • Oct 12 2016 22:33
    dreanor closed #17
  • Oct 12 2016 22:33
    dreanor closed #62
Dreanor
@dreanor
meep
vadivel1234
@vadivel1234

Hi,

I have developed a “Windows Service Application” and my part of coding is below. I got the below mentioned exception when run the line starts with Client.DownloadFile(..) though included the

“ServicePointManager.Expect100Continue = true;
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;”

Am running this service in Windows Server 2012 R2 machine.

Code:

 ``` public static bool DownloadDocument(string path, string id)
    {
        try
        {
            string[] FileName = path.Split('/');
            WebClient Client = new WebClient();
            ServicePointManager.Expect100Continue = true;
            ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
            string DocumentLocation = Service._currentDirectoryPath + @"Attachments";
            string Url = path;

            if (System.IO.Directory.Exists(DocumentLocation) == false)
            {

                System.IO.Directory.CreateDirectory(DocumentLocation + "\\" + id);

            }
            else
            {

                System.IO.Directory.Delete(DocumentLocation, true);
                System.IO.Directory.CreateDirectory(DocumentLocation + "\\" + id);
            }
            byte[] _crdential = UTF8Encoding.UTF8.GetBytes(Service.UserName + ":" + Service.Password);
            Client.Headers[HttpRequestHeader.Authorization] = string.Format("Basic {0}", Convert.ToBase64String(_crdential));
            Client.DownloadFile(new Uri(Url), DocumentLocation + "\\" + id + "\\" + FileName[FileName.Count() - 1]);

            return true;
        }
        catch (Exception exc)
        {
            LogError.LogMessageToFile(id + " - Exception in DownloadDocument() - " + exc.Message + Environment.NewLine + exc.StackTrace);
            return false;
        }
    }

```

Error log details:

11/6/2019 6:38:55 PM: BRD-21817 - Exception in DownloadDocument() - The request was aborted: Could not create SSL/TLS secure channel.
at System.Net.WebClient.DownloadFile(Uri address, String fileName)
at Publish_Service.DocumentHandle.DownloadDocument(String path, String id).

11/6/2019 6:38:55 PM: Exception in PublishDetails() - Could not find file 'F:\Publish_Service\brd-21817.html'.
at System.IO.Error.WinIOError(Int32 errorCode, String maybeFullPath)
at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost)
at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost)
at System.IO.StreamReader..ctor(String path, Encoding encoding, Boolean detectEncodingFromByteOrderMarks, Int32 bufferSize, Boolean checkHost)
at System.IO.StreamReader..ctor(String path, Encoding encoding)
at HtmlAgilityPack.HtmlDocument.Load(String path)
at Publish_Service.DocumentHandle.CheckH1ElementOccurance(String id)
at Publish_Service.Service.<PublishDetails>d
20.MoveNext().

I have tried the solutions suggested in below links. But not helps. Still issue occurring when I run this service.

https://stackoverflow.com/questions/2859790/the-request-was-aborted-could-not-create-ssl-tls-secure-channel
https://stackoverflow.com/questions/39307684/webclient-error-when-downloading-file-from-https-url

Any help on this would be greatly appreciated.

Regards,
Karthi