Keep it Simple

// practice, the distance between dream and achievement

Tag: WebRequest (page 1 of 2)

SSL – Underlying connection was closed

If you’ve ever had to make a web request to an HTTPS endpoint from C# you will likely run into this gem of an exception.

The underlying connection was closed: Could not establish trust relationship for the SSL/TLS secure channel.

Who the what now?

Continue reading

Download images from a URL in C#

You may use the following method to retrieve the image from a specific URL on the web. The below C# function takes an image url, download the image from the url as a stream.

Continue reading

Download an image with the appropriate extension using WebClient

I had to retrieve and save an image from the external websites to my local folder. While it can look like a simple task at the first glance, it can be complicated when you try to find the filename & extension using the URL.


though this is an Image, you would not be able to find the filename or extension by using the URL, so I had to come up with this.

Continue reading

WebClient Timeout

The issue occurs when the time for generating the whole response of a WebClient request is longer than the default timeout (2 minutes) . So the solution is to increase this timeout value.

The WebClient class doesn’t have such property or method, so you have 2 possibilities:

  1. Use HttpWebRequest instead of WebClient and set its timeout by ReadWriteTimeout property. Of course the usage of this class is more complex than WebClient one but it gives you more flexibility.
  2. Make a derived class (wrapper) , which will set the timeout property of the base class of the WebClient.

Continue reading

Older posts

© 2017 Keep it Simple

Theme by Anders NorenUp ↑