I have 2 urls:
https://static.summitracing.com/global/images/prod/xlarge/cse-5160_xl.jpg http://www.americanbassusa.com/Subwoofers/DX-Series-Images/DX/DX-front.jpg
Both download the corresponding images correctly when opened in Chrome but when using the following console application to download them using WebClient.DownloadData(String), the second url causes a System.Net.WebException to be thrown.
Can any one provide me with an understanding as to why this is happening?
class Program
{
static void Main(string[] args)
{
const string WorkingUrl = "https://static.summitracing.com/global/images/prod/xlarge/cse-5160_xl.jpg";
const string NonWorkingUrl = "http://www.americanbassusa.com/Subwoofers/DX-Series-Images/DX/DX-front.jpg";
try
{
using (var client = new WebClient())
{
byte[] fileData = client.DownloadData(NonWorkingUrl);
}
}
catch (Exception e)
{
Console.WriteLine(e);
}
Console.ReadLine();
}
}
The exception details are:
System.Net.WebException: The remote server returned an error: (400) Bad Request.
at System.Net.WebClient.DownloadDataInternal(Uri address, WebRequest& request)
at System.Net.WebClient.DownloadData(Uri address)
at System.Net.WebClient.DownloadData(String address)
at ConsoleApp4.Program.Main(String[] args) in C:\\Users\\davidandrewpowell\\source\\repos\\ConsoleApp4\\ConsoleApp4\\Program.cs:line 17