472,127 Members | 1,750 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,127 software developers and data experts.

More File download questions

I am trying to implment a file download via a link such that when clicked,
instead of starting the default application for that type of file the user
will be presented with a download dialog window. Well, thanks to Steve Orr,
I have that working. However, I still have a few issues. First, the
download dialog does not have the name of the file being downloaded in the
"File name" field, instead it has the name of the aspx page that have the
code to send the file to the client. Second, also in the download dialog,
the "File type" field has nothing in it. The code from my aspx page that is
doing the download is below. Is there ome other header that I can add that
will cause the download dialog to have the correct file name and file type
in it? Also, I'd liek to refresh the clling page so that the list of items
left to download nolonger includes the item just downloaded. If there
anyway to do that in this aspx page (adding a response.redirect to the page
that the download link is on doesn't work). I tried adding and event handler
on the download page that refreshed when the link was clicked but it
refreshed before the download started. Thanks for any help you can provide.
<%@ Import Namespace="MyAssembly" %>
<%@ Import Namespace="System" %>
<%@ Import Namespace="System.IO" %>
<%@ Import Namespace="System.Xml" %>
'''''''''''''''''''''''''''''''''''''''''''''''''' '''''''''''''''''''''''''
Blah Blah Blah - just doing some validation at the
database'''''''''''''''''''''''''''''''''''''''''' ''''''''''''''''''''''''''

dim di as new DataInterface()
Dim gf as new genFuncs()
Dim doc As object
Dim FileName As String
Dim MyFileInfo As FileInfo
Dim StartPos, FileSize As Long
dim retval as string
dim funcRet as string
dim sessionid as string
dim errors as string
dim songid as integer
dim header as string
dim logid as int64
dim currentorder as string

sessionid = iif(request.querystring("s")=nothing, "",
songid = cint(iif(request.querystring("song")=nothing, "0",
logid = clng(iif(request.querystring("log")=nothing, "-1",
currentorder = iif(request.querystring("order")=nothing, "",

funcRet = di.Connect(sessionid)
if left(funcRet, 4) = "Fail" then
GoTo ExitPage
end if

doc = gf.loadXDoc(di.getValidateDownload(logid), errors)
if doc.DocumentElement.SelectSingleNode("//@status").innerText = "fail"
response.redirect("orderdownload.aspx?s=" & sessionid & "&order=" &
goto exitpage
end if

doc = gf.loadXDoc(di.getSongInfo(songid), errors)

Dim docRoot as XmlElement = doc.DocumentElement

FileName = di.songLocation & "\" & _

docRoot.SelectSingleNode("//genreDirectory").innerText & "\" & _
docRoot.SelectSingleNode("//labelID").innerText &
"\" & _
MyFileInfo = New FileInfo(FileName)
FileSize = MyFileInfo.Length

'''''''''''''''''''''''''''''''''''''''''''''''''' '''''''''''''''''''''''''
End database stuff
'''''''''''''''''''''''''''''''''''''''''''''''''' ''''''''''''''''''''''''''

'''''''''''''''''''''''''''''''''''''''''''''''''' '''''''''''''''''''''''''
Here's the important stuff
'''''''''''''''''''''''''''''''''''''''''''''''''' ''''''''''''''''''''''''''
response.contenttype = "audio/x-mpeg"
header = "attachment;filename=" & FileName
Response.WriteFile(FileName, StartPos, FileSize)

'''''''''''''''''''''''''''''''''''''''''''''''''' '''''''''''''''''''''''''
End important stuff
'''''''''''''''''''''''''''''''''''''''''''''''''' ''''''''''''''''''''''''''
retVal = di.updDownloadedSong(logid) 'marks the teh download record so
that this item can only be downloaded once.
Nov 17 '05 #1
0 1722

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

13 posts views Thread by Ken | last post: by
4 posts views Thread by Bernhard | last post: by
2 posts views Thread by Tom Youngquist | last post: by
14 posts views Thread by Aaron | last post: by
2 posts views Thread by John Spiegel | last post: by
3 posts views Thread by Nate Hekman | last post: by
5 posts views Thread by Bala | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.