Android browser won't download pdf file

后端 未结 1 376
星月不相逢
星月不相逢 2021-01-18 11:47

I have a web app that lets users download a pdf file. It is ASP.NET MVC and it all works fine on desktop browsers, iPhone, Android Chrome, and in a native Android app that o

1条回答
  •  甜味超标
    2021-01-18 12:00

    Found my own answer and it was so much simpler than where I was looking. My page with the download link is in an iframe. Something in the Android default browser loses your download if it occurs in an iframe. I added target="_blank" to the a tag that initiates the download and everything now works fine.

    Here is some sample code to demonstrate the the problem and the fix.

    
    Test page
    
    
        
            Download sample pdf