Search code examples
asp.netgoogle-chromepdfpdfium

Built-in Chrome PDF Viewer does not fully load large PDF file for authenticated users in ASP.NET Web App


The Built-in Chrome PDF Viewer does not fully load large PDF files for authenticated users.

Steps to reproduce in my environment:

  1. In Visual Studio 2019 create a new WebForms project with Individual User Accounts authentication
  2. In solution explorer create some folder e.g. MyPDFs and put inside some large pdf file.
  3. Secure this folder with web.config:

    <location path="MyPDFs"> <system.web> <authorization> <deny users="?" /> </authorization> </system.web> </location>

    and for this testing purposes set runAllManagedModulesForAllRequests to true:

    <modules runAllManagedModulesForAllRequests="true">

  4. Run this site with IISExpress and navigate to ~/MyPDFs/A17_FlightPlan.pdf in my case it is https://localhost:44302/pdfs/A17_FlightPlan.pdf

  5. The login screen appears, after user successful logins the pdf is partially rendered (only first page) by built-in Chrome PDF viewer (pdfium) partially rendered image

  6. When you remove authorization rule from web.config, or you put the PDF file to some other location, it is loaded correctly

  7. The same behavior I can reproduce on production - Full IIS

  8. Other browsers work fine: FireFox, EDGE, or even Chrome with replaced built-in PDF viewer for Adobe Acrobat reader extension

Where could be the problem? Are the headers OK?

Response headers


Solution

  • It was a bug in Google Chrome. In Chrome Version 81.0.4044.43 (Official Build) beta (64-bit) it seems working.