QueryString
을 가져 와서 클라이언트에 파일을 스트리밍하는 ASP.Net 웹 페이지를 작성했습니다. 파일은 SQL Server 데이터베이스에 저장됩니다. 개발 과정에서 웹 사이트를 로컬로 실행할 때 모든 것이 잘 작동합니다. 서버에서 프로덕션 환경으로 실행하면 Firefox가 아닌 Chrome을 통해 파일을 가져올 수 있습니다. Chrome에서 얻을 수 있습니다. Error 100 (net::ERR_CONNECTION_CLOSED): Unknown error.
스트림 파일이 깨졌습니다. Firefox 작동
이 게시물은 Content-Length
과 관련 될 수 있다고 언급했는데, 이것이 개발 과정이 아닌 제작 과정에서 작동하는 이유를 알 수 없습니다. 그런 이유로 나는 여기서 다른 일이 일어나고 있다고 생각합니다.
제안/힌트를 주셔서 감사합니다. 다음과 같이
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim Data_ID As String = Request.QueryString("Data_ID")
Using dt As New Enterprise_Error_Log.Field_FileDataTable
Using ta As New Field_FileTableAdapter
ta.Fill(dt, Data_ID)
If dt.Rows.Count > 0 Then
Dim myRow As Enterprise_Error_Log.Field_FileRow = dt.Rows(0)
Dim myFileName As String = myRow("Field_File_Name")
'Dim myFileData() As Byte = myRow("Field_File")
Dim myFileLength As String = myRow("Field_File_Length")
Response.BufferOutput = False
Response.AddHeader("Content-Disposition", "inline;filename=""" & myFileName & """")
Response.AddHeader("Content-Length", myFileLength)
StreamFile(Data_ID)
Response.Close()
End If
End Using
End Using
End Sub
Private Sub StreamFile(ByVal Data_ID As String)
Dim bolGotContentType As Boolean = False
Using conn = New SqlConnection(Enterprise_Error_LogConnectionString.ConnectionString)
Using cmd = conn.CreateCommand()
conn.Open()
cmd.CommandText = "SELECT Field_File FROM Ext_Error_Log WHERE (Data_ID = @Data_ID)"
cmd.Parameters.AddWithValue("@Data_ID", Data_ID)
Using reader = cmd.ExecuteReader(Data.CommandBehavior.SequentialAccess)
While reader.Read()
Dim buffer As Byte() = New Byte(8040) {}
' Read chunks of 1KB
Dim bytesRead As Long = 0
Dim dataIndex As Long = 0
Do
'read next chunk
bytesRead = reader.GetBytes(0, dataIndex, buffer, 0, buffer.Length)
If bytesRead > 0 Then
'advance index
dataIndex += bytesRead
'if this is the first chunk, get the mime type from it.
If Not bolGotContentType Then
Response.ContentType = "application/octet-stream" 'getMimeFromFile(buffer)
bolGotContentType = True
End If
Response.BinaryWrite(buffer)
Response.Flush()
End If
Loop Until bytesRead = 0
End While
End Using
End Using
End Using
End Sub
내 헤더
은 다음과 같습니다 : 여기 내 코드 내가 HTTP 추적 도구의 실제 응답을 검사하는 것이 좋습니다Cache-Control: private
Date: Mon, 24 Jan 2011 20:37:33 GMT
Content-Length: 3153269
Content-Type: application/octet-stream
Content-Disposition: attachment;filename="C:\Users\CBARTH\AppData\Local\Temp\tmp4BC8.mdmp.gz";size=3153169
Server: Microsoft-IIS/6.0
X-AspNet-Version: 2.0.50727
X-Powered-By: ASP.NET
Content-Encoding: gzip
콘텐츠 처리를위한 코드가 깨졌습니다. (파일 이름이 공백을 포함하는 경우) 또는 이스케이프 (ISO-8859-1이 아닌 경우) –
값을 따옴표로 묶으십시오. 헤더 검사에서도 따옴표로 묶여 있음을 나타내기도합니다. 아마도 당신이 말하는 것을 놓친 것 같습니다. – cjbarth