https web request asp.net code example

Example 1: https request c#

HttpWebRequest req = (HttpWebRequest)WebRequest.Create("http://requestbin.net/r/xxxxxxxx?" + textBox2.Text);
req.GetResponse();

Example 2: .net core c# webrequest download

byte[] listeByte;
            try
            {
                
                FtpWebRequest requestFichier = (FtpWebRequest)WebRequest.Create(@filePath);
                requestFichier.Credentials = new NetworkCredential(utilisateur, motDePasse);
                requestFichier.Method = WebRequestMethods.Ftp.DownloadFile;
                using (WebResponse response = await requestFichier.GetResponseAsync())
                {
                    using (MemoryStream ms = new MemoryStream())
                    {
                        response.GetResponseStream().CopyTo(ms);
                        listeByte = ms.ToArray();
                    }
                }
            }
            catch (Exception ex)
            {
               throw ex;
            }

            return listeByte;