More File download questions

B

Buddy Ackerman

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, "",
request.querystring("s"))
songid = cint(iif(request.querystring("song")=nothing, "0",
request.querystring("song")))
logid = clng(iif(request.querystring("log")=nothing, "-1",
request.querystring("log")))
currentorder = iif(request.querystring("order")=nothing, "",
request.querystring("order"))

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

doc = gf.loadXDoc(di.getValidateDownload(logid), errors)
if doc.DocumentElement.SelectSingleNode("//@status").innerText = "fail"
then
response.redirect("orderdownload.aspx?s=" & sessionid & "&order=" &
currentorder)
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 &
"\" & _
docRoot.SelectSingleNode("//songFile").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.AddHeader("Content-Disposition",header)
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.


ExitPage:
%>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,774
Messages
2,569,599
Members
45,175
Latest member
Vinay Kumar_ Nevatia
Top