Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics AX forum
Unanswered

Download file from https

Posted on by 3,985

I am trying to download some html from a homepage, and it works when i try to get the data from the http:// link, but if i try with the https:// link then it fails.
With the https link my files contains some string saying that i need to clear my cache and try again. (The string i get is in danish so posting it here is probably not helpful)

I am using this code.

static void TestDownloadHttpsArgs _args)
{
System.Net.WebClient myWebClient;
str content;
FileName outFile = @"C:\Temp\Result.fil";
str url = "somwdomain/somefile.htm";

;
new InteropPermission(InteropKind::ClrInterop).assert();

myWebClient = new System.Net.WebClient();
myWebClient.DownloadFile(url,outFile);
}

Does anyone have any idea how to fix the cashing problem?

I have tried changing caching settings in my internet explorer, but that seems to make no difference.

  • Martin Dráb Profile Picture
    Martin Dráb 228,041 Super User 2024 Season 2 on at
    RE: Download file from https

    Fiddler is an HTTP proxy used for debugging, traffic recording and so on.

  • Rudi Hansen Profile Picture
    Rudi Hansen 3,985 on at
    RE: Download file from https

    And now i also got the link to work in IE, but still i get the same problem in AX.

    Even if i run AX as the same user as where IE works.

    And i also tried restarting the server, AOS and all, it still does not work :-(

  • Rudi Hansen Profile Picture
    Rudi Hansen 3,985 on at
    RE: Download file from https

    Hi Jonathan, i tried accepting the certificate, and that did not help.

    But i learned one thing from it, actually when i try to open the link in the IE browser i get the same error as with AX, (I am using Chrome on the machine, and with that it works perfectly)

    So the problem is properly more related to IE than my code, so perhaps that will help me finding the problem.

  • Jonathan  Halland Profile Picture
    Jonathan Halland 11,304 on at
    RE: Download file from https

    Hi Rudi.

    I'm not sure if I can help you in this specific instance, but I have come across issues when accessing "secure" content via either C# or X++ where you need to accept the certificate being issued by the site before you can access the content. You can try accomplish this by accessing the content in Internet explorer, viewing the sites certificate and adding it manually to your certificate store.

    To do this automatically in code is a bit more complex and depending on your scenario may not be entirely necessary.

    This may not solve your issue, but we did struggle with unexplained errors because of this.

  • Rudi Hansen Profile Picture
    Rudi Hansen 3,985 on at
    RE: Download file from https

    Well i do not really get any error messages, the file i get just contains this string.

    "Beklager - Ryd venligst din browsers cache, og prøv igen. Test evt. med incognito mode (in private mode).<br>Aktiveres med CTRL+SHIFT+N eller CTRL+SHIFT+P. I denne tilstand er alle personlige browser-data fjernet midlertidigt."

    Translation, please clear your browser cache.

    I don't know what Fiddler is.

  • Martin Dráb Profile Picture
    Martin Dráb 228,041 Super User 2024 Season 2 on at
    RE: Download file from https

    The exact error message would help, as well as information about the web server response (e.g. HTTP status code). Fiddler might help to collect more information.

  • Rudi Hansen Profile Picture
    Rudi Hansen 3,985 on at
    RE: Download file from https

    Yes, (Knew i should have put that in the original post)

  • Martin Dráb Profile Picture
    Martin Dráb 228,041 Super User 2024 Season 2 on at
    RE: Download file from https

    Can you open the URL in browser?

Helpful resources

Quick Links

Dynamics 365 Community Update – Sep 9th

Welcome to the next edition of the Community Platform Update. This is a weekly…

Announcing Our 2024 Season 2 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 290,246 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 228,041 Super User 2024 Season 2

#3
nmaenpaa Profile Picture

nmaenpaa 101,148

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans