Search code examples
c#resttimeoutwebclientdownloadstring

C# WebClient DownloadString suddenly gives timeout after months


About a year ago I made a tool to update our outdated Dell BIOS files automatically, but today it suddenly stopped working. I'm using the REST API the Dell site calls when surfing manually.

This is the request I send with the added header underneath:

GET http://www.dell.com/support/home/be/nl/bebsdt1/drivers/driverslist/platfromdriver?productCode=latitude-15-5580-laptop&osCode=WT64A
X-Requested-With: XMLHttpRequest

The strange thing is that it still works when using it with a request manipulator like HttpRequester (for firefox). I'm sure no other headers like UserAgent are sent.

The code in C# (with one model):

WebClient wc = new WebClient();
wc.Headers.Add("X-Requested-With: XMLHttpRequest");
wc.QueryString.Add("name", "5580");
wc.DownloadStringCompleted += Wc_DownloadStringCompleted;
wc.DownloadStringAsync(new Uri("http://www.dell.com/support/home/be/nl/bebsdt1/drivers/driverslist/platfromdriver?productCode=latitude-15-5580-laptop&osCode=WT64A"));

I tested using Async or not, but for this issue it doesn't make a difference. A timeout is returned as an error.

Can anyone help me out?


Solution

  • Use this.

    WebClient wc = new WebClient();
    wc.Headers.Add("X-Requested-With","XMLHttpRequest");
    wc.Headers.Add("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8");
    wc.Headers.Add("Accept-Language", "en-US,en;q=0.9");
    var response = wc.DownloadString("https://www.dell.com/support/home/in/en/inbsdt1/drivers/driverslist/platfromdriver?productCode=latitude-15-5580-laptop&osCode=WT64A&name=5580");
    Console.WriteLine(response);