继续尝试通过https下载文件,可以在http上正常运行,但是在Firefox中收到消息-“无法保存文件名,因为无法读取源文件”和“失败-网络错误”在Chrome中。 / p>
Web应用程序位于Cisco防火墙后面,在该防火墙中我打开了所有端口,但仍然没有任何乐趣。絮状的。
Dim file As System.IO.FileInfo = New System.IO.FileInfo(FullFilePath) '-- if the file exists on the server
If file.Exists Then 'set appropriate headers
Response.ClearContent()
Response.ClearHeaders()
Dim iStream As System.IO.Stream = Nothing
' Buffer to read 10K bytes in chunk:
Dim buffer(10000) As Byte
' Length of the file:
Dim length As Integer
' Total bytes to read:
Dim dataToRead As Long
Try
' Open the file.
iStream = New System.IO.FileStream(FullFilePath, System.IO.FileMode.Open,
IO.FileAccess.Read, IO.FileShare.Read)
' Total bytes to read:
dataToRead = iStream.Length
'Response.ContentType = "application/octet-stream"
Response.ContentType = "application/pdf"
'Response.ContentType = WebApp.Common.Functions.ReturnContentType(file.Extension.ToLower())
Response.AddHeader("Content-Disposition", "attachment; filename=""" & file.Name & """")
' Read the bytes.
While dataToRead > 0
' Verify that the client is connected.
If Response.IsClientConnected Then
' Read the data in buffer
length = iStream.Read(buffer, 0, 10000)
' Write the data to the current output stream.
Response.OutputStream.Write(buffer, 0, length)
' Flush the data to the HTML output.
Response.Flush()
ReDim buffer(10000) ' Clear the buffer
dataToRead = dataToRead - length
Else
'prevent infinite loop if user disconnects
dataToRead = -1
End If
End While
Catch ex As Exception
' Trap the error, if any.
Response.Write("Error : " & ex.Message)
Finally
If iStream IsNot Nothing Then
' Close the file.
iStream.Close()
End If
Response.Close()
End Try
Response.End() 'if file does not exist
Else
Response.Write("This file does not exist.")
End If 'nothing in the URL as HTTP GET