1

I've tried to implement the solution given on Download files in MAUI iOS WebView almost exactly, but the resulting file contents only contain the name of the file, not the expected document contents.

Is there some extra code needed for either the NSUrlSessionCreateDownloadTask(url) in the StartDownload() method, or is there more code needed in the MyDownloadDelegate class? Maybe there is another direction I can take altogether?

8
  • Have you checked the source URL if it is correct? You may also refer to this thread, WebView on iOS cann't download file Commented May 30 at 6:22
  • 1
    Thanks for you response, Liqun. The source URL works correctly on Android, plus I can download directly on a browser with the same source URL. Thanks also for the reference link, however, it has pretty much the same code I am already using.
    – Mark Bisho
    Commented May 30 at 18:11
  • 1
    Upon further investigation, I see that the system is unable to display the file contents as a PDF, which is why all I see is the file name. When I look at the contents, I see the login page for the site from which I am trying to download the PDF. It appears that even though I am logged into the site in the webview, my session isn't being passed in the request (as part of the cookie). When the app tries to access the file, it is being redirected to the login page and that html is being downloaded, instead.
    – Mark Bisho
    Commented May 30 at 23:36
  • 1
    The code provided in the link above doesn't discuss how to handle a cookie or a session. Is there any code example that does that?
    – Mark Bisho
    Commented May 30 at 23:37
  • Here is a related issue on GitHub, WebView Cookies not working, which is tagged as fixed now Commented May 31 at 5:57

0

Browse other questions tagged or ask your own question.