Web Connection
Response.DownloadFile
Gravatar is a globally recognized avatar based on your email address. Response.DownloadFile
  Rod
  All
  Jun 26, 2017 @ 12:50pm

Hi all, I'm rendering PDFs on a virtual folder and trying to download them to the client using Response.DownloadFile(). When I render the file, I use the full windows path out to the folder that's mapped as virtual on IIS. When I try and download it passing the same path, I get a message: "Couldn't read the requested file on the server. Most likely permissions don't allow access to the requested file." I'm using that virtual for all sorts of IIS reads, so I don't think it's a permission issue. I read an older post here that says that function hands off to an IIS download function. So I thought maybe I should pass the virtual path, but of course WW does recognize that. I'm not getting something...

Any help appreciated! Rod

Gravatar is a globally recognized avatar based on your email address. re: Response.DownloadFile
  Rod
  Rod
  Jun 26, 2017 @ 01:00pm

FYI, I created a folder directly under the web folder for this, and I have my WWC app writing the PDFs there instead of to the virtual. That works I need to create a sub-folder for each client. So download does not work with a virtual?

Gravatar is a globally recognized avatar based on your email address. re: Response.DownloadFile
  Rick Strahl
  Rod
  Jun 26, 2017 @ 06:39pm

Code?

I'm guessing you're not referencing the file correctly. Download file takes a physical file to download so make sure the path is correct. The file is served by IIS and the file has to stick around after your request is done as IIS picks up that file after the request completes. Maybe you're deleting the file before it's been sent or the file is still locked from writing?

+++ Rick ---

Gravatar is a globally recognized avatar based on your email address. re: Response.DownloadFile
  Rod
  Rick Strahl
  Jun 27, 2017 @ 04:23am

I am not deleting the files. I assumed it was pathing code, but I think I have it right.

I'm creating the file with oPDF.PrintReport(): \web7\D\Sites\RFCTest\objects\reports\RW00000035.pdf

That web7 server hosts the various client sites, the folders of which I am sharing from my site, and the root of those sites, \web7\d\sites" is mapped on my site in IIS as a virtual "RW7Sites".

Then I'm passing this virtual path to downloadfile(): RW7Sites\RFCTest\objects\reports\RW00000035.pdf

The wild card is that web7 is a remote server, and as I said, I have the right permissions, and my IIS site uses it to load images, but maybe it doesn't like it as a physical path for download?

Anyway, I am content to move the temp folder for downloads to a physical folder/subfolder structure under IIS on the local server, which works.

Gravatar is a globally recognized avatar based on your email address. re: Response.DownloadFile
  Rick Strahl
  Rod
  Jun 27, 2017 @ 10:22am

It's hard to tell, but the thing to do is log out the file name as it's being sent to DownloadFile() and check that that file indeed exists. My guess it does not. The issue almost certainly will be that the file wasn't written by the PDF generation - reading is usually less of an issue.

IIS can read the file from any location on disk as long as IIS (Application Pool) has permissions to read from the external folder. This goes for the managed module - I believe the ISAPI module requires that the file lives in the virtual Web folder tree.

+++ Rick ---

© 1996-2024