I have actaully been working on something like this for a while. You have to set your headers of a dummy page and then set that as the src of IFRame in your parent page. I can not for the life of me get the thing to open inside the page. It always wants to open powerpoint, or excel (depending on file type) and open the file inside the app. My boss insists on it opening in the page.
vb
'test for session data to prevent exception when app hits this twice
If Not Session("fileName") Is Nothing And Not Session("mimeType") Is Nothing Then
'get the filename and mimetype from session
Dim fileName As String = Session("fileName").ToString
Dim mimeType As String = Session("mimeType").ToString
Dim path As String = Server.MapPath(Common.materialPath)
Dim file As System.IO.FileInfo = New System.IO.FileInfo(path + fileName)
If file.Exists Then
'if file exists, set the header info
Response.Clear()
Response.ContentType = mimeType
Response.AddHeader("Content-Disposition", "inline; filename=" & file.Name)
Response.AddHeader("Content-Length", file.Length.ToString())
Response.WriteFile(file.FullName)
Response.End()
End If
End If
It is my understanding that the "inline" in this line:
Response.AddHeader("Content-Disposition", "inline; filename=" & file.Name)is to make it open in the page. Psycho do you have any ideas on this?