F
frenchie seb via .NET 247
Hi !
here's the code of the function I use to send a file to the client :
Private Function SendFile(ByVal fich As String, ByVal nom As String) As Boolean
Try
Dim oldCT As String = Response.ContentType
Response.Clear()
Response.ContentType = "application/octet-stream"
Response.AddHeader("Content-Disposition", "attachment; filename=""" & nom & """")
Dim fi As IO.FileInfo = New IO.FileInfo(Server.MapPath("fichiers\") & fich)
If Not fi.Exists Then
Return False
Exit Function
End If
Dim fs As IO.FileStream = fi.OpenRead
Dim tab(fs.Length) As Byte
fs.Read(tab, 0, fs.Length)
fs.Close()
Response.BinaryWrite(tab)
Response.Flush()
Response.Close()
Response.Clear()
Response.ContentType = oldCT
Return True
Catch ex As Exception
Return False
End Try
End Function
When I call it, the transfer works fine, the file is ok, but the web application stops responding to the client. When the client clicks a link or tries to do something on the page, nothing happens and the status bar indicates "Error on page"
Has someone an idea ?
Thanks in advance
here's the code of the function I use to send a file to the client :
Private Function SendFile(ByVal fich As String, ByVal nom As String) As Boolean
Try
Dim oldCT As String = Response.ContentType
Response.Clear()
Response.ContentType = "application/octet-stream"
Response.AddHeader("Content-Disposition", "attachment; filename=""" & nom & """")
Dim fi As IO.FileInfo = New IO.FileInfo(Server.MapPath("fichiers\") & fich)
If Not fi.Exists Then
Return False
Exit Function
End If
Dim fs As IO.FileStream = fi.OpenRead
Dim tab(fs.Length) As Byte
fs.Read(tab, 0, fs.Length)
fs.Close()
Response.BinaryWrite(tab)
Response.Flush()
Response.Close()
Response.Clear()
Response.ContentType = oldCT
Return True
Catch ex As Exception
Return False
End Try
End Function
When I call it, the transfer works fine, the file is ok, but the web application stops responding to the client. When the client clicks a link or tries to do something on the page, nothing happens and the status bar indicates "Error on page"
Has someone an idea ?
Thanks in advance