469,592 Members | 1,674 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,592 developers. It's quick & easy.

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, "",
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:
%>
Nov 17 '05 #1
0 1628

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 this site, you agree to our Privacy Policy and Terms of Use.