저는 Excel 스프레드 시트를 생성하고 응답 (콘텐츠 처리 헤더)에서 보내는 ASP.NET 페이지가 있습니다. 그 부분은 잘 작동하지만 원본 페이지가 응답의 일부가 아니기 때문에 절대로 다시 사용할 수없는 단추가 있습니다. 나는 응답을 삭제하고 대신 AddHeader의 AppendHeader를 사용하지만, 응답이 여전히 파일이 포함되지 시도HTTP 응답으로 파일과 페이지를 보내려면 어떻게해야합니까?
Public Shared Sub WriteToResponse(ByVal theWorkBook As Workbook, ByVal FileName As String, ByVal resp As HttpResponse)
Dim theStream As New System.IO.MemoryStream()
theWorkBook.Save(theStream)
Dim byteArr As Byte() = DirectCast(Array.CreateInstance(GetType(Byte), theStream.Length), Byte())
theStream.Position = 0
theStream.Read(byteArr, 0, CInt(theStream.Length))
theStream.Close()
resp.Clear()
resp.AddHeader("content-disposition", "attachment; filename=" & FileName)
resp.BinaryWrite(byteArr)
resp.End()
End Sub
:
여기 내가 사용하는 기능입니다.
무엇이 누락 되었습니까? 다른 헤더를 사용해야합니까? 나는 이것을 발견했다 unanswered question on the ASP.NET forums; 내 문제 같아.