I ran into an interesting issue as I was adding the download component for my net site.
Using the sample code from the following article, I was attempting to initiate a file download.
CodeGuru: ASP.NET Tip: Control Access to a File Download
The problem I encountered was my download test harness was inside of an Atlas UpdatePanel and the way the sample code above works, is to inject content into the Web Response to be delivered to the client.
Needless to say, the absolute last thing the UpdatePanel expected to receive was a 250K ZIP file when all the user ( me ) did was to click on a link.
What really irritated me was the fact that I could not tell until very late in the process that it was actually the UpdatePanel causing the problem. Most of the time was spent trying to figure out where to put files so that GoDaddy would actually let me touch them. More on those issues in a later article.
Anyway, the solution is to simply create a page whose entire existance is to do nothing but download files using a page parameter. Put the actual download code in the code-behind, verify the filename parameter and make sure the user has logged in. The code in the above article does the rest.
One final note, if you are downloading things that can be displayed in a browser, like a JPEG file, the probability is high that the file is not downloaded, but merely displayed in a browser.
Leave a reply