From: | Rick Strahl |
To: | David Pedrelli |
IIS 7 and later introduces this change. If you're running IIS 6 or earlier (Win2003 or XP) the code will work. With IIS 7 and later it won't.
+++ Rick ---
Rick,
That is the part that I don't understand. I am using the exact same code in another app, under the same Web site. I pulls the same file, from the same directory, which is not in the Web folder structure of either app. Yet, it works in one app, but not the other one. Is there just an inconsistency with IIS?
The files contain protected information; so, I cannot put them anywhere that unauthorized people may be able to access them. FileToStr() won't work because they may be larger than 16 MBs.
Thanks,
David
DownloadFile only works with files in the Web folder structure, not files in arbitrary folders. This is a limitation in IIS and TransmitFile() which is used behind the scenes to service the file directly (and very efficiently) from disk.
Just make sure any files you write out are in the virtual directory folder hierarchy of your Web application to ensure that the transmit file will work.
If that doesn't work then you have to explicitly stream the file through code using Response.Write() (either using FILETOSTR() or a low level FREAD() loop).
+++ Rick ---
Hi,
I have two WC 5 apps running on Windows 7. I am running them both inside of VFP, with pass-through authentication. The Windows user is an administrator. Both apps are running under the same IIS Web site. They are two different virtual directories, each with its own script map.
In one of them, I used RESPONSE.DownloadFile to download a file that is not accessible through the public Web site. It works fine. I copied the Web page and the .prg to the second app. The only thing that I changed is the extension of the Web page to match the script map. I am attempting the download the exact same file, from the same directory, running under the same user. It works fine in the first app. The second app gives me the following error:
Unable to download file
We were unable to send the requested file to the client.
'd:\pdfs\20130422\1\test2.pdf' is not a valid virtual path.
--------------------------------------------------------------------------------
Message generated by Web Connection IIS Connector Module
Here is the code that is in my Web page. THIS.oEntry is an instance variable for a wwBusiness object, which is instantiated in a parent wwWebPage class. Again, this same code works in the other app and the file is not accessible from the public Web site for either app.
FUNCTION OnLoad()
DODEFAULT()
IF NOT EMPTY(THIS.cID) THEN
THIS.DowloadRequestFile()
ENDIF
ENDFUNC
FUNCTION DowloadRequestFile()
sSQL = "SELECT * FROM roi.tbl_REQUEST_FILES WHERE FK_REQUEST = "
sSQL = sSQL + SESSION.GetSessionVar(THIS.cSessionVarRequestID)
sSQL = sSQL + " AND ID = " + THIS.cID
IF THIS.oEntry.Query(sSQL, "TDownload") = 1 THEN
RESPONSE.DownloadFile(TDownload.FilePath + TDownload.Filename)
ENDIF
ENDFUNC
West Wind Technologies
Making waves on the Web