我已被敲我的头靠在墙上与铬此古怪行为

我具有存储在一个未命名的,无序的状态在磁盘上加密的文件。当文件由用户下载的,客户端重定向到下载处理程序(ashx的)的数据被加载到一个数据流,解密和发送到客户端。现在,这一直很好,直到最近,

它工作正常,在除铬所有浏览器所在的文件下载到一个名为.gz文件不可读?

我已剥出流提取和加密的部分为了简洁(记住这完美地工作于IE,火狐等)

    Private Function StreamFile(ByVal context As System.Web.HttpContext) As Boolean

    context.Response.Clear()
    context.Response.ClearHeaders()
    context.Response.BufferOutput = False
    context.Response.ContentType = "application/octet-stream"
    context.Response.AddHeader("content-disposition", "attachment;filename=""" & _sFileName & """")
    context.Response.AddHeader("content-length", _iSize)
    context.Response.Cache.SetNoServerCaching()
    context.Response.Cache.SetMaxAge(System.TimeSpan.Zero)

    Dim oInputStream As System.IO.Stream = GetStream()
    Dim oBufferedStream As New BufferedStream(oFileStream, context.Response.OutputStream)
    oBufferedStream.ProcessStreams(True)

    context.ApplicationInstance.CompleteRequest()

    Return True

End Function

Public Class BufferedStream
    Private _oInputStream As Stream
    Private _oOutputStream As Stream
    Private _bBuffer() As Byte
    Public Const DEFAULT_BUFFER_SIZE As Integer = 8192

    Public Sub New(ByRef oInputStream As Stream, ByRef oOutputStream As Stream)
        _oInputStream = oInputStream
        _oOutputStream = oOutputStream
        _bBuffer = GetStreamBuffer(ToInteger(_oInputStream.Length))
    End Sub

    Public Function ProcessStreams(ByVal bCloseStreams As Boolean) As Boolean

        Dim iRead As Integer = 0
        Dim iStreamLength As Integer = ToInteger(_oInputStream.Length)

        Try
            iRead = _oInputStream.Read(_bBuffer, 0, _bBuffer.Length)
            While iRead > 0
                _oOutputStream.Write(_bBuffer, 0, _bBuffer.Length)
                iRead = _oInputStream.Read(_bBuffer, 0, _bBuffer.Length)
                If iRead < _bBuffer.Length Then System.Array.Resize(_bBuffer, iRead)
            End While

            If bCloseStreams Then
                Close()
            End If
            Return True

        Catch
            Return False
        End Try
    End Function

    Public Shared Function GetStreamBuffer(ByVal iStreamSize As Integer) As Byte()
        Dim iBufferSize As Integer = iStreamSize - 1
        If iBufferSize > DEFAULT_BUFFER_SIZE Then iBufferSize = DEFAULT_BUFFER_SIZE
        Dim bBuffer As Byte() = New Byte(iBufferSize) {}
        Return bBuffer
    End Function

End Class

任何帮助,将不胜感激。

下面是从提琴手HTTP报头时在文件中的铬被下载

HTTP/1.1 200 OK
Date: Fri, 30 Oct 2009 00:01:45 GMT
Server: Microsoft-IIS/6.0
X-Powered-By: ASP.NET
X-AspNet-Version: 2.0.50727
content-disposition: attachment;filename="codeKiwi.txt"
Content-Length: 349
Cache-Control: private, max-age=0
Content-Type: application/octet-stream

请注意,该文件名是codekiwi.txt和内容是一些简单的纯文本,该文件被保存为codekiwi.txt.gz和包含乱码。

有帮助吗?

解决方案

好了,解决了它自己。我原来,铬(和Firefox)真的不喜欢的response.ClearHeaders呼吁,由于某种原因,IE是确定这一点,一旦我删除它的下载充当再次预期...

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top