Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

File Download prblem

Status
Not open for further replies.

lpatnaik

Programmer
Jul 11, 2002
53
hey i have a slight problem with dotnet file download. can you help me out. I am downloading a file by clicking on a likn in an aspx page. that i do by using the code:
Sub DownloadSelectedFile()

Dim strFilename As String = Request.Form("h_uc_Filename")

Dim fileInfo As FileInfo

Dim intStartPos As Long = 0, intFileSize As Long, intEndPos As Long

fileInfo = New FileInfo(strFilename)

intFileSize = fileInfo.Length

intEndPos = intFileSize

HttpContext.Current.Response.AppendHeader("Content-disposition", "attachment; filename=" & fileInfo.Name)

HttpContext.Current.Response.WriteFile(strFilename, intStartPos, intEndPos)

End Sub



But this code is downloadin the aspx file sometimes rather than downloading the reqd file (doc/xls). can you help me out.?
 
if you step through the code, do you find that the variable strFileName is being set to the name of the page itself? if so, that would be the area of code I'd look at first. Maybe something in the logic thats grabbing the wrong name.

i.e.
this bit of code
Request.Form("h_uc_Filename")
looks for h_uc_Filename, right? are you sure that its getting the right value? if not value is supplied, is it defaulting to the page? etc.

D
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top