0

I'm trying to get a CSV file with exchange rates from a URL on a bank's web site. When I manually access the link in a browser, I can download the exchange rates. Even on development machine (Win10, IIS 10) the code works fine to access the file. The problem arises when I move the app to the production server (Win2012 R2, IIS 8.5).

The WebException Response: <!DOCTYPE html> <html class="ltr" dir="ltr" lang="sk"><head> <title>Nepodporovaný prehliadač - ČSOB</title> <meta content="text/html; charset=UTF-8" http-equiv="content-type"> <link href="data:image/x-icon;base64,AAABAAEAEBAAAAEAIABoBAAAF... and it goes on like this - around 65 000 characters.

Nepodporovaný prehliadač = unsupported browser.

I tried setting the user agent as suggested here: .net webclient returns 500 error, but url in browser is fine:

WebClient client = new WebClient();

client.Headers["User-Agent"] = "Mozilla/5.0 (Windows; U; MSIE 9.0; Windows NT 9.0; en-US)";

The exception still arises even with the user agent set this way.

I tried using WebRequest instead of WebClient (as suggested here: How to get content from file from this URL?) but the same exception happens with Error 500 and Response in WebException saying unsupported browser.

The URL I'm trying to access: https://www.csob.sk/delegate/getExchangeRatesExport?EXPORT_TYPE=CSV&DISPLAY=CURRENCY&DATE=2019011607

All the methods I've tried work fine in development but fail in production. The WebClient code worked perfectly fine on production server for like a year until yesterday - probably the bank changed something. Any help would be much appreciated.

UrAn
  • 43
  • 1
  • 5
  • try to set `user-agent` the same as on developer machine. IE9 may be unsupported. – Alex Kudryashev Jan 16 '19 at 21:54
  • I tried setting the `user-agent` to `Mozilla/5.0 (Windows NT 6.3; Win64; x64; rv:64.0) Gecko/20100101 Firefox/64.0` but no luck there. Still the same exception and unsupported browser message... – UrAn Jan 17 '19 at 09:26
  • 1
    It seems to me that `user-agent` has nothing to do with this error, even though it should. Unless the bank's response is wrong and the unsupported browser message is supposed to be something else or it has a deeper meaning. – UrAn Jan 17 '19 at 09:44

0 Answers0