That is something I tried to figure out for a while also, but once you see
an example it is actually quite simple. Here is an example I used I created,
along with the website that taught me how to do it:
Private Sub btnDownload_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnDownload.Click
Response.ClearContent()
Response.ContentType = "text/plain"
Response.AddHeader("content-disposition",
"attachment;filename=download.txt")
'Response.WriteFile(Server.MapPath("download.txt"))
Response.Write("This is a test download text file" &
ControlChars.NewLine)
Response.Write(Date.Now.ToLongDateString() & " " &
Date.Now.ToLongTimeString())
Response.End()
End Sub
My example asks the user to download a text file that contains the string
"This is a test download text file" followed by the date & time (note the
two Response.Write lines). If you want to give the user a file instead, set
the Response.ContentType to the appropriate string and use
Response.WriteFile instead (I have this line commented out, you will have to
uncomment it). You can also, if you want, use a combination of WriteFile and
Write when sending a text file. For more details, see the following site
which is where I learned how to do this:
http://www.dotnetspider.com/technology/kbpages/553.aspx
Good Luck!