By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
464,372 Members | 1,223 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 464,372 IT Pros & Developers. It's quick & easy.

More File download questions

P: n/a
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
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.