Download a File to the Client Browser using Response.WriteFile - October 2008

I found a handy tip on the web, written by Marco Bellinaso, that shows how to cause a file to be downloaded. The tip shows how to use the Server and Response objects to perform the download. So why not just provide the URL to that web page and forget about making this a tip?

Marco's Tip URL:

Because the tip says you must include the code in a page in order to access the Server and Response objects. This restriction can be eliminated by using HttpContext.Current to prefix the objects. For example:


I modified Marco's code and put it into a class module. A typical calling sequence is:

Dim oDF As New cDownloadFile

Which will open a dialog similar to:



Download VB.Net Code

Click here to download the VS2005 VB.Net source code [1k].

Previous Tip   Tip Index   Next Tip


Updated 2011/04/22